RegressionTests__QDoubleTests.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 18:53:03 +0200
changeset 2327 bf482d49aeaf
parent 2270 960a8b13323c
child 2417 6821e4990968
permissions -rw-r--r--
#QUALITY by exept class: RegressionTests::StringTests added: #test82c_expanding
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2270
960a8b13323c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
     1
"{ Encoding: utf8 }"
960a8b13323c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
     2
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ Package: 'stx:goodies/regression' }"
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
"{ NameSpace: RegressionTests }"
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
TestCase subclass:#QDoubleTests
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	instanceVariableNames:''
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
	classVariableNames:''
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
	poolDictionaries:''
1627
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
    11
	category:'tests-Regression-Numbers'
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
!QDoubleTests class methodsFor:'documentation'!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
documentation
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
"
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
    documentation to be added.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
    [author:]
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
        cg
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
    [instance variables:]
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
    [class variables:]
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
    [see also:]
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
"
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
! !
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
!QDoubleTests methodsFor:'tests'!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
1620
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    34
test99_misc
2195
864930fc306d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
    35
     self skip:'unfinished work in progress'.
864930fc306d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
    36
     
1620
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    37
     self assert:( 1 asQDouble / (3 factorial) - (QDouble invFact at:1) ) = 0.0. 
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    38
     self assert:( 1 asQDouble / (4 factorial) - (QDouble invFact at:2) ) = 0.0. 
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    39
     self assert:( 1 asQDouble / (5 factorial) - (QDouble invFact at:3) ) = 0.0. 
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    40
     self assert:( 1 asQDouble / (6 factorial) - (QDouble invFact at:4) ) = 0.0. 
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    41
     self assert:( 1 asQDouble / (7 factorial) - (QDouble invFact at:5) ) = 0.0. 
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    42
     self assert:( 1 asQDouble / (8 factorial) - (QDouble invFact at:6) ) = 0.0. 
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    43
     self assert:( 1 asQDouble / (9 factorial) - (QDouble invFact at:7) ) = 0.0. 
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    44
     self assert:( 1 asQDouble / (10 factorial) - (QDouble invFact at:8) ) = 0.0. 
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    45
     self assert:( 1 asQDouble / (11 factorial) - (QDouble invFact at:9) ) = 0.0. 
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    46
     self assert:( 1 asQDouble / (12 factorial) - (QDouble invFact at:10) ) = 0.0. 
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    47
     self assert:( 1 asQDouble / (13 factorial) - (QDouble invFact at:11) ) = 0.0. 
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    48
     self assert:( 1 asQDouble / (14 factorial) - (QDouble invFact at:12) ) = 0.0. 
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    49
     self assert:( 1 asQDouble / (15 factorial) - (QDouble invFact at:13) ) = 0.0. 
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    50
     self assert:( 1 asQDouble / (16 factorial) - (QDouble invFact at:14) ) = 0.0. 
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    51
     self assert:( 1 asQDouble / (17 factorial) - (QDouble invFact at:15) ) = 0.0.
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    52
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    53
    "Created: / 20-06-2017 / 13:06:04 / cg"
2195
864930fc306d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
    54
    "Modified: / 28-03-2019 / 12:20:51 / Claus Gittinger"
1620
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    55
!
e19b7dd63097 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1619
diff changeset
    56
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
test_01_instance_creation
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    58
    |q|
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    59
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    60
    q := QDouble fromFloat:1.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    61
    self assert:(q d0 = 1.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    62
    self assert:(q d1 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    63
    self assert:(q d2 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    64
    self assert:(q d3 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    65
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    66
    q := 1.0 asQDouble.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    67
    self assert:(q d0 = 1.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    68
    self assert:(q d1 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    69
    self assert:(q d2 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    70
    self assert:(q d3 = 0.0).
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    72
    q := 1e40 asQDouble + 1.0 asQDouble.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    73
    self assert:(q d0 = 1e40).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    74
    self assert:(q d1 = 1.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    75
    self assert:(q d2 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    76
    self assert:(q d3 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    77
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    78
    q := 1e40 asQDouble + 1.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    79
    self assert:(q d0 = 1e40).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    80
    self assert:(q d1 = 1.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    81
    self assert:(q d2 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    82
    self assert:(q d3 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    83
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    84
    q := 1e120 asQDouble + 1e40 + 1.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    85
    self assert:(q d0 = 1e120).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    86
    self assert:(q d1 = 1e40).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    87
    self assert:(q d2 = 1.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    88
    self assert:(q d3 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    89
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    90
    q := 1e200 asQDouble + 1e120 + 1e40 + 1.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    91
    self assert:(q d0 = 1e200).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    92
    self assert:(q d1 = 1e120).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    93
    self assert:(q d2 = 1e40).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    94
    self assert:(q d3 = 1.0).
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    "
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
     self run:#test_01_instance_creation
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
     self new test_01_instance_creation
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    "
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    "Created: / 12-06-2017 / 17:03:46 / cg"
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   102
    "Modified: / 20-06-2017 / 07:48:51 / cg"
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   103
    "Modified: / 05-06-2019 / 20:15:30 / Claus Gittinger"
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
test_02_addition
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    |d1 d2 l1 l2 sum_l q1 q2 sum_d sum_q|
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   109
    "/ self skip:'unfinished work in progress'.
2195
864930fc306d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
   110
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    d1 := 1.0.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    d2 := 1.0e-16.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    sum_d := d1 + d2.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    "/ precision is lost with doubles!!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    self assert:( sum_d - 1.0 = 0.0 ).
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    l1 := 1.0 asLongFloat.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    l2 := 1.0e-16 asLongFloat.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    sum_l := l1 + l2.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    "/ no precision is lost with long doubles!!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    self assert:( (sum_l - (1.0 asLongFloat)) > 0.0 ).
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
1607
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   123
    l1 := 1.0 asLongFloat.
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   124
    l2 := 1.0e-30 asLongFloat.
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   125
    sum_l := l1 + l2.
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   126
    "/ precision is lost!!
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   127
    self assert:( (sum_l - (1.0 asLongFloat)) = 0.0 ).
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   128
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    q1 := QDouble fromFloat:1.0.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    q2 := QDouble fromFloat:1.0e-16.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    sum_q := q1 + q2.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    
1607
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   133
    "/ no precision is lost
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   134
    self assert:( (sum_q - (QDouble fromFloat:1.0)) > 0.0 ).
1614
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   135
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   136
    q1 := QDouble fromFloat:1.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   137
    q2 := QDouble fromFloat:2.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   138
    sum_q := q1 + q2.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   139
    self assert:( sum_q = 3.0 ).
1607
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   140
    
1614
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   141
    q1 := QDouble fromFloat:1.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   142
    q2 := QDouble fromFloat:2.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   143
    sum_q := q1 + 2.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   144
    self assert:( sum_q = 3.0 ).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   145
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   146
    q1 := QDouble fromFloat:1.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   147
    q2 := QDouble fromFloat:2.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   148
    sum_q := 1.0 + q2.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   149
    self assert:( sum_q = 3.0 ).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   150
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   151
    q1 := 1e200 asQDouble + 1e120 + 1e40 + 1.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   152
    q2 := 1e120.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   153
    sum_q := q1 + q2.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   154
    self assert:(sum_q d0 = 1e200).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   155
    self assert:(sum_q d1 = 2e120).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   156
    self assert:(sum_q d2 = 1e40).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   157
    self assert:(sum_q d3 = 1.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   158
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    "
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
     self run:#test_02_addition
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
     self new test_02_addition
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
    "
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    "Created: / 12-06-2017 / 17:05:07 / cg"
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   165
    "Modified: / 20-06-2017 / 07:49:32 / cg"
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   166
    "Modified: / 05-06-2019 / 20:15:38 / Claus Gittinger"
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
test_03_subtract
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    |d1 d2 l1 l2 diff_l q1 q2 diff_d diff_q|
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   172
    "/ self skip:'unfinished work in progress'.
2195
864930fc306d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
   173
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
    d1 := 1.0.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    d2 := 0.99999.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    diff_d := d1 - d2.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
    "/ precision is lost with doubles!!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    l1 := 1.0 asLongFloat.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
    l2 := 0.99999 asLongFloat.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
    diff_l := l1 - l2.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    "/ no precision is lost with long doubles!!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    q1 := QDouble fromFloat:1.0.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
    q2 := QDouble fromFloat:0.99999.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
    diff_q := q1 - q2.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
    
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
    "
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
     self run:#test_03_subtract
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
     self new test_03_subtract
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
    "
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
    "Created: / 12-06-2017 / 23:12:00 / cg"
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   195
    "Modified: / 05-06-2019 / 20:16:12 / Claus Gittinger"
1608
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   196
!
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   197
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   198
test_04_relops
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   199
    "/ self skip:'unfinished work in progress'.
2195
864930fc306d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
   200
1608
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   201
    self assert:(1.0 = 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   202
    self assert:(1.0 asQDouble = 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   203
    self assert:(1.0 asQDouble = 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   204
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   205
    self assert:(1 = 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   206
    self assert:(1 asQDouble = 1).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   207
    self assert:(1 asQDouble = 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   208
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   209
    self assert:(1 = 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   210
    self assert:(1.0 asQDouble = 1).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   211
    self assert:(1.0 asQDouble = 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   212
    
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   213
    self assert:(1.0 = 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   214
    self assert:(1 asQDouble = 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   215
    self assert:(1 asQDouble = 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   216
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   217
    
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   218
    self deny:(1.0 = 1.1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   219
    self deny:(1.0 asQDouble = 1.1).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   220
    self deny:(1.0 asQDouble = 1.1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   221
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   222
    self deny:(1 = 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   223
    self deny:(1 asQDouble = 2).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   224
    self deny:(1 asQDouble = 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   225
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   226
    self deny:(1 = 2.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   227
    self deny:(1.0 asQDouble = 2).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   228
    self deny:(1.0 asQDouble = 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   229
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   230
    self deny:(2.0 = 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   231
    self deny:(2 asQDouble = 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   232
    self deny:(2 asQDouble = 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   233
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   234
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   235
    
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   236
    self assert:(1.0 < 1.1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   237
    self assert:(1.0 asQDouble < 1.1).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   238
    self assert:(1.0 asQDouble < 1.1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   239
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   240
    self assert:(1 < 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   241
    self assert:(1 asQDouble < 2).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   242
    self assert:(1 asQDouble < 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   243
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   244
    self assert:(1 < 2.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   245
    self assert:(1.0 asQDouble < 2).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   246
    self assert:(1.0 asQDouble < 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   247
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   248
    self assert:(1.0 < 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   249
    self assert:(1 asQDouble < 2.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   250
    self assert:(1 asQDouble < 2.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   251
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   252
    
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   253
    self deny:(1.0 < 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   254
    self deny:(1.0 asQDouble < 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   255
    self deny:(1.0 asQDouble < 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   256
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   257
    self deny:(1 < 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   258
    self deny:(1 asQDouble < 1).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   259
    self deny:(1 asQDouble < 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   260
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   261
    self deny:(1 < 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   262
    self deny:(1.0 asQDouble < 1).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   263
    self deny:(1.0 asQDouble < 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   264
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   265
    self deny:(1.0 < 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   266
    self deny:(1 asQDouble < 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   267
    self deny:(1 asQDouble < 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   268
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   269
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   270
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   271
    self assert:(2.0 > 1.1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   272
    self assert:(2.0 asQDouble > 1.1).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   273
    self assert:(2.0 asQDouble > 1.1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   274
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   275
    self assert:(3 > 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   276
    self assert:(3 asQDouble > 2).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   277
    self assert:(3 asQDouble > 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   278
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   279
    self assert:(3 > 2.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   280
    self assert:(3.0 asQDouble > 2).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   281
    self assert:(3.0 asQDouble > 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   282
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   283
    self assert:(3.0 > 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   284
    self assert:(3 asQDouble > 2.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   285
    self assert:(3 asQDouble > 2.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   286
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   287
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   288
    self deny:(1.0 > 3.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   289
    self deny:(1.0 asQDouble > 3.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   290
    self deny:(1.0 asQDouble > 3.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   291
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   292
    self deny:(1 > 3 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   293
    self deny:(1 asQDouble > 3).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   294
    self deny:(1 asQDouble > 3 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   295
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   296
    self deny:(1 > 3.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   297
    self deny:(1.0 asQDouble > 3).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   298
    self deny:(1.0 asQDouble > 3 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   299
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   300
    self deny:(1.0 > 3 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   301
    self deny:(1 asQDouble > 3.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   302
    self deny:(1 asQDouble > 3.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   303
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   304
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   305
    self assert:(1.0 <= 3.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   306
    self assert:(1.0 asQDouble <= 3.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   307
    self assert:(1.0 asQDouble <= 3.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   308
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   309
    self assert:(1.0 <= 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   310
    self assert:(1.0 asQDouble <= 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   311
    self assert:(1.0 asQDouble <= 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   312
    
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   313
    self assert:(2.0 >= 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   314
    self assert:(2.0 asQDouble >= 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   315
    self assert:(2.0 asQDouble >= 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   316
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   317
    self assert:(1.0 >= 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   318
    self assert:(1.0 asQDouble >= 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   319
    self assert:(1.0 asQDouble >= 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   320
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   321
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   322
    
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   323
    self assert: ((1.0 asQDouble + 1e-40) > 1.0 asQDouble).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   324
    self assert: (1.0 asQDouble < (1.0 asQDouble + 1e-40)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   325
    self assert: (1.0 asQDouble < (1.0 asQDouble + 1e-80)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   326
    self assert: (1.0 asQDouble < (1.0 asQDouble + 1e-120)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   327
    self assert: (1.0 asQDouble < (1.0 asQDouble + 1e-300)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   328
    self assert: (1.0 asQDouble < (1.0 asQDouble + 1e-300)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   329
    
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   330
    self assert: ((1.0 asQDouble + 1e-40) > 1.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   331
    self assert: (1.0 < (1.0 asQDouble + 1e-40)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   332
    self assert: (1.0 < (1.0 asQDouble + 1e-80)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   333
    self assert: (1.0 < (1.0 asQDouble + 1e-120)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   334
    self assert: (1.0 < (1.0 asQDouble + 1e-300)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   335
    self assert: (1.0 < (1.0 asQDouble + 1e-300)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   336
1619
75c3687a4f4d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
   337
    self assert: (1e10 asQDouble + 1.0) = 10000000001.0.
75c3687a4f4d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
   338
    "/ that's the problem with Floats...
75c3687a4f4d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
   339
    "/ (1e20 asQDouble + 1.0) ~= 100000000000000000001.0. 
75c3687a4f4d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
   340
    "/ (1e20 + 1.0) - 1e20 ~= 1.0. 
75c3687a4f4d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
   341
    self assert: (1e20 asQDouble + 1.0) - 1e20 = 1.0. 
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   342
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   343
    "/ here the precision of QDOubles is no longer enough:
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   344
    "/ self assert:  1.0 asQDouble < (1.0 asQDouble + 1e-310).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   345
1608
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   346
    "
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   347
     self run:#test_03_subtract
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   348
     self new test_03_subtract
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   349
    "
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   350
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   351
    "Created: / 13-06-2017 / 17:11:37 / cg"
1619
75c3687a4f4d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
   352
    "Modified (comment): / 20-06-2017 / 09:18:50 / cg"
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   353
    "Modified: / 05-06-2019 / 20:16:21 / Claus Gittinger"
1614
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   354
!
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   355
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   356
test_05_multiply
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   357
    |q1 q2 p|
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   358
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   359
    "/ self skip:'unfinished work in progress'.
2195
864930fc306d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
   360
1614
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   361
    q1 := QDouble fromFloat:3.0. "/ DoubleArray(2.0 0.0 0.0 0.0)
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   362
    p := 2.0 * q1.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   363
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   364
    self assert:(p d0 = 6.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   365
    self assert:(p d1 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   366
    self assert:(p d2 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   367
    self assert:(p d3 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   368
    self assert:(p = 6.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   369
    self assert:(6.0 = p).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   370
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   371
    q1 := QDouble fromFloat:2.0. "/ DoubleArray(2.0 0.0 0.0 0.0)
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   372
    p := q1 * 3.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   373
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   374
    self assert:(p d0 = 6.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   375
    self assert:(p d1 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   376
    self assert:(p d2 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   377
    self assert:(p d3 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   378
    self assert:(p = 6.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   379
    self assert:(6.0 = p).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   380
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   381
    q1 := QDouble fromFloat:2.0. "/ DoubleArray(2.0 0.0 0.0 0.0)
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   382
    q2 := QDouble fromFloat:3.0. "/ DoubleArray(3.0 0.0 0.0 0.0)
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   383
    p := q1 * q2.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   384
    
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   385
    self assert:(p d0 = 6.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   386
    self assert:(p d1 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   387
    self assert:(p d2 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   388
    self assert:(p d3 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   389
    self assert:(p = 6.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   390
    self assert:(6.0 = p).
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   391
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   392
    "/ the 1 is not forgotten!!
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   393
    q1 := 1 asQDouble + 1e40.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   394
    q2 := 2.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   395
    p := q1 * q2.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   396
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   397
    self assert:(p d0 = 2e40).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   398
    self assert:(p d1 = 2.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   399
    self assert:(p d2 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   400
    self assert:(p d3 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   401
    self assert:(p > 2e40).
1751
b025e8468c85 *** empty log message ***
sr
parents: 1627
diff changeset
   402
    self assert:(p - 2e40) = 2.0.
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   403
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   404
    "/ nothing is forgotten!!
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   405
    q1 := 1 asQDouble + 1e40 + 1e120.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   406
    q2 := 2.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   407
    p := q1 * q2.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   408
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   409
    self assert:(p d0 = 2e120).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   410
    self assert:(p d1 = 2e40).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   411
    self assert:(p d2 = 2.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   412
    self assert:(p d3 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   413
    self assert:(p > 2e120).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   414
    self assert:(p > (2e120 asQDouble + 2)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   415
    self assert:(p > (2e120 asQDouble + 1e40)).
1751
b025e8468c85 *** empty log message ***
sr
parents: 1627
diff changeset
   416
    self assert:(p - 2e120) = (2 asQDouble + 2e40).
b025e8468c85 *** empty log message ***
sr
parents: 1627
diff changeset
   417
    self assert:(p - 2e120 - 2e40) = 2.0.
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   418
1614
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   419
    "
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   420
     self run:#test_05_multiply
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   421
     self new test_05_multiply
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   422
    "
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   423
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   424
    "Created: / 19-06-2017 / 16:58:29 / cg"
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   425
    "Modified (comment): / 20-06-2017 / 07:42:52 / cg"
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   426
    "Modified: / 05-06-2019 / 20:16:30 / Claus Gittinger"
1616
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   427
!
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   428
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   429
test_06_exp
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   430
    |f1 q1|
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   431
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   432
    "/ self skip:'unfinished work in progress'.
2195
864930fc306d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
   433
1623
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   434
    f1 := 2.0 exp.
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   435
    q1 := 2.0 asQDouble exp.
1616
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   436
1623
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   437
    "/ the first 113 digits are:
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   438
    "/                                            7.3890560989306502272304274605750078131803155705518473240871278225225737960790577633843124850791217947737531612654...
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   439
    "/ 2.0 exp             
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   440
    "/ '%30.28f' printf:{ 2.0 exp }           -> '7.38905609893065040694182243896'
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   441
    "/ '%30.28f' printf:{ 2.0 exp asQDouble } -> '7.38905609893065040694182243897'
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   442
    "/ '%30.28f' printf:{ 2.0 asQDouble exp } -> '7.38905609893065022723042746058'
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   443
    "/ '%40.38f' printf:{ 2.0 asQDouble exp } -> '7.389056098930650227230427460575007822092' (10 iters in exp)
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   444
    "/ '%40.38f' printf:{ 2.0 asQDouble exp }    
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   445
    "/ 2.0 asQDouble exp   -> 7.3890560989306502272304274605750078* 220914983921672'
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   446
    "/ 1.0 asQDouble exp       
1616
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   447
    self assert:(q1 d0 = f1).
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   448
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   449
    "
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   450
     self run:#test_06_exp
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   451
     self new test_06_exp
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   452
    "
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   453
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   454
    "Created: / 19-06-2017 / 17:58:08 / cg"
1623
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   455
    "Modified (comment): / 21-06-2017 / 13:45:56 / cg"
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   456
    "Modified: / 05-06-2019 / 20:16:35 / Claus Gittinger"
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   457
!
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   458
1627
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   459
test_06b_log10
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   460
    |q1 q2 d3a q3a d3b q3b q4 i|
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   461
2270
960a8b13323c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
   462
    "/ self skip:'unfinished work in progress'.
2195
864930fc306d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
   463
1627
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   464
    q1 := QDouble d0: 5.55111512312578E-18 
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   465
                  d1: -3.08148791101958E-34 
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   466
                  d2: 1.71056941445901E-50 
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   467
                  d3: 0.0.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   468
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   469
    q2 := 10 / q1.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   470
    self assert:(q2 > 1e18).
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   471
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   472
    d3a := q2 asFloat ln.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   473
    self assert:(d3a isNaN not).
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   474
    
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   475
    q3a := q2 ln.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   476
    self assert:(q3a isNaN not).
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   477
    
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   478
    d3b := q2 asFloat log10.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   479
    self assert:(d3b isNaN not).
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   480
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   481
    q3b := q2 log10.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   482
    self assert:(q3b isNaN not).
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   483
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   484
    q4 := q3b floor.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   485
    i := q4 asInteger.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   486
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   487
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   488
    "
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   489
     self run:#test_06b_log10
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   490
     self new test_06b_log10
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   491
    "
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   492
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   493
    "Created: / 03-07-2017 / 10:31:53 / cg"
2270
960a8b13323c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
   494
    "Modified: / 05-06-2019 / 20:18:26 / Claus Gittinger"
1627
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   495
!
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   496
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   497
test_07_reading
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   498
    |q1 s|
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   499
2270
960a8b13323c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
   500
    "/ self skip:'unfinished work in progress'.
2195
864930fc306d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
   501
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   502
    q1 := QDouble readFrom: '3.1415926535897'.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   503
    s := '%55.54f' printf:{ q1 }.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   504
    self assert:(s = '                                        3.1415926535897').
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   505
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   506
    q1 := QDouble readFrom: '3.141592653589793238462643383'.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   507
    s := '%55.54f' printf:{ q1 }.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   508
    self assert:(s = '                          3.141592653589793238462643383').
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   509
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   510
    q1 := QDouble readFrom: '3.141592653589793238462643383279502884197169399375105820'.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   511
    s := '%55.54f' printf:{ q1 }.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   512
    self assert:(s = '3.14159265358979323846264338327950288419716939937510582').
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   513
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   514
    "
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   515
     self run:#test_07_reading
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   516
     self new test_07_reading
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   517
    "
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   518
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   519
    "Created: / 19-06-2017 / 23:29:34 / cg"
2270
960a8b13323c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
   520
    "Modified: / 05-06-2019 / 20:18:51 / Claus Gittinger"
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   521
!
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   522
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   523
test_08_conversion
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   524
    |q i|
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   525
    
2270
960a8b13323c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
   526
    "/ self skip:'unfinished work in progress'.
2195
864930fc306d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
   527
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   528
    q := 1e10 asQDouble + 1.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   529
    i := q asInteger.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   530
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   531
    self assert:(i = 10000000001).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   532
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   533
    "
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   534
     self run:#test_08_conversion
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   535
     self new test_08_conversion
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   536
    "
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   537
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   538
    "Created: / 20-06-2017 / 07:51:50 / cg"
2270
960a8b13323c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
   539
    "Modified: / 05-06-2019 / 20:18:48 / Claus Gittinger"
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
! !
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
!QDoubleTests class methodsFor:'documentation'!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
version
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
    ^ '$Header$'
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
version_CVS
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
    ^ '$Header$'
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
! !
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551