RegressionTests__QDoubleTests.st
author Claus Gittinger <cg@exept.de>
Tue, 25 Feb 2020 17:19:49 +0100
changeset 2586 7dc7be5a6f3d
parent 2454 7d1bfada3e52
permissions -rw-r--r--
#OTHER by cg s
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/regression' }"
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ NameSpace: RegressionTests }"
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
TestCase subclass:#QDoubleTests
2436
ae3aaedd0b32 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2435
diff changeset
     6
	instanceVariableNames:''
ae3aaedd0b32 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2435
diff changeset
     7
	classVariableNames:''
ae3aaedd0b32 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2435
diff changeset
     8
	poolDictionaries:''
ae3aaedd0b32 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2435
diff changeset
     9
	category:'tests-Regression-Numbers'
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!QDoubleTests class methodsFor:'documentation'!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
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 to be added.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
    [author:]
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
    19
	cg
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
    [instance variables:]
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
    [class 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
    [see also:]
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
"
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
!QDoubleTests methodsFor:'tests'!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
test_01_instance_creation
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    33
    |q|
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    34
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    35
    q := QDouble fromFloat:1.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    36
    self assert:(q d0 = 1.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    37
    self assert:(q d1 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    38
    self assert:(q d2 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    39
    self assert:(q d3 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    40
2417
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
    41
    q := QDouble fromInteger:1.
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
    42
    self assert:(q d0 = 1.0).
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
    43
    self assert:(q d1 = 0.0).
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
    44
    self assert:(q d2 = 0.0).
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
    45
    self assert:(q d3 = 0.0).
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
    46
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
    47
    q := 1 asQDouble.
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
    48
    self assert:(q d0 = 1.0).
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
    49
    self assert:(q d1 = 0.0).
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
    50
    self assert:(q d2 = 0.0).
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
    51
    self assert:(q d3 = 0.0).
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
    52
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    53
    q := 1.0 asQDouble.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    54
    self assert:(q d0 = 1.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    55
    self assert:(q d1 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    56
    self assert:(q d2 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    57
    self assert:(q d3 = 0.0).
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    59
    q := 1e40 asQDouble + 1.0 asQDouble.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    60
    self assert:(q d0 = 1e40).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    61
    self assert:(q d1 = 1.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    62
    self assert:(q d2 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    63
    self assert:(q d3 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    64
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    65
    q := 1e40 asQDouble + 1.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    66
    self assert:(q d0 = 1e40).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    67
    self assert:(q d1 = 1.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    68
    self assert:(q d2 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    69
    self assert:(q d3 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    70
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    71
    q := 1e120 asQDouble + 1e40 + 1.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    72
    self assert:(q d0 = 1e120).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    73
    self assert:(q d1 = 1e40).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    74
    self assert:(q d2 = 1.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    75
    self assert:(q d3 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    76
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    77
    q := 1e200 asQDouble + 1e120 + 1e40 + 1.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    78
    self assert:(q d0 = 1e200).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    79
    self assert:(q d1 = 1e120).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    80
    self assert:(q d2 = 1e40).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    81
    self assert:(q d3 = 1.0).
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    "
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
     self run:#test_01_instance_creation
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
     self new test_01_instance_creation
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    "
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    "Created: / 12-06-2017 / 17:03:46 / cg"
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
    89
    "Modified: / 20-06-2017 / 07:48:51 / cg"
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
    90
    "Modified: / 05-06-2019 / 20:15:30 / Claus Gittinger"
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
test_02_addition
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    |d1 d2 l1 l2 sum_l q1 q2 sum_d sum_q|
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    d1 := 1.0.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    d2 := 1.0e-16.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    sum_d := d1 + d2.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    "/ precision is lost with doubles!!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    self assert:( sum_d - 1.0 = 0.0 ).
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   101
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    l1 := 1.0 asLongFloat.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    l2 := 1.0e-16 asLongFloat.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    sum_l := l1 + l2.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    "/ no precision is lost with long doubles!!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    self assert:( (sum_l - (1.0 asLongFloat)) > 0.0 ).
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
1607
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   108
    l1 := 1.0 asLongFloat.
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   109
    l2 := 1.0e-30 asLongFloat.
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   110
    sum_l := l1 + l2.
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   111
    "/ precision is lost!!
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   112
    self assert:( (sum_l - (1.0 asLongFloat)) = 0.0 ).
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   113
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    q1 := QDouble fromFloat:1.0.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    q2 := QDouble fromFloat:1.0e-16.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    sum_q := q1 + q2.
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   117
2419
7efaf9133e12 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   118
    "/ no precision is lost with qDoubles
1607
00dc6d97bc10 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   119
    self assert:( (sum_q - (QDouble fromFloat:1.0)) > 0.0 ).
2419
7efaf9133e12 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   120
    self assert:( (sum_q - (QDouble fromFloat:1.0)) = 1.0e-16 ).
7efaf9133e12 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   121
7efaf9133e12 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   122
    q1 := QDouble fromFloat:1.0.
7efaf9133e12 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   123
    q2 := QDouble fromFloat:1.0e-30.
7efaf9133e12 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   124
    sum_q := q1 + q2.
7efaf9133e12 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   125
7efaf9133e12 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   126
    "/ no precision is lost with qDoubles
7efaf9133e12 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   127
    self assert:( (sum_q - (QDouble fromFloat:1.0)) > 0.0 ).
7efaf9133e12 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2418
diff changeset
   128
    self assert:( (sum_q - (QDouble fromFloat:1.0)) = 1.0e-30 ).
1614
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   129
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   130
    q1 := QDouble fromFloat:1.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   131
    q2 := QDouble fromFloat:2.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   132
    sum_q := q1 + q2.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   133
    self assert:( sum_q = 3.0 ).
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   134
1614
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   135
    q1 := QDouble fromFloat:1.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   136
    q2 := QDouble fromFloat:2.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   137
    sum_q := q1 + 2.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   138
    self assert:( sum_q = 3.0 ).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   139
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   140
    q1 := QDouble fromFloat:1.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   141
    q2 := QDouble fromFloat:2.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   142
    sum_q := 1.0 + q2.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   143
    self assert:( sum_q = 3.0 ).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   144
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   145
    q1 := 1e200 asQDouble + 1e120 + 1e40 + 1.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   146
    q2 := 1e120.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   147
    sum_q := q1 + q2.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   148
    self assert:(sum_q d0 = 1e200).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   149
    self assert:(sum_q d1 = 2e120).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   150
    self assert:(sum_q d2 = 1e40).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   151
    self assert:(sum_q d3 = 1.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   152
2417
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
   153
    '%.60f' printf:{QDouble pi}
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
   154
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
    "
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
     self run:#test_02_addition
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
     self new test_02_addition
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    "
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
    "Created: / 12-06-2017 / 17:05:07 / cg"
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   161
    "Modified: / 20-06-2017 / 07:49:32 / cg"
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   162
    "Modified: / 05-06-2019 / 20:15:38 / Claus Gittinger"
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
2445
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   165
test_02b_addition
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   166
    |q1 q2 sum_q|
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   167
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   168
    q1 := 1.0e20 asQDouble.
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   169
    q2 := 1.0e-16 asQDouble.
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   170
    sum_q := q1 + q2.
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   171
    self assert:( sum_q - q1 = q2 ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   172
    self assert:( sum_q - q2 = q1 ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   173
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   174
    sum_q := sum_q + 1e-30.
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   175
    self assert:( sum_q - q1 -q2 = 1e-30 ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   176
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   177
    sum_q := sum_q + 1e10.
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   178
    self assert:( sum_q - q1 - q2 - 1e10 = 1e-30 ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   179
    self assert:( sum_q - q1 - q2 - 1e-30 = 1e10 ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   180
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   181
    "
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   182
     self run:#test_02b_addition
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   183
     self new test_02b_addition
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   184
    "
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   185
!
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   186
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
test_03_subtract
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
    |d1 d2 l1 l2 diff_l q1 q2 diff_d diff_q|
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
    d1 := 1.0.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    d2 := 0.99999.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
    diff_d := d1 - d2.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
    "/ precision is lost with doubles!!
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   194
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
    l1 := 1.0 asLongFloat.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    l2 := 0.99999 asLongFloat.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
    diff_l := l1 - l2.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    "/ no precision is lost with long doubles!!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    q1 := QDouble fromFloat:1.0.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    q2 := QDouble fromFloat:0.99999.
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    diff_q := q1 - q2.
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   204
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
    "
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
     self run:#test_03_subtract
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
     self new test_03_subtract
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    "
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    "Created: / 12-06-2017 / 23:12:00 / cg"
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   211
    "Modified: / 05-06-2019 / 20:16:12 / Claus Gittinger"
1608
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
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   214
test_04_relops
2195
864930fc306d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
   215
1608
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   216
    self assert:(1.0 = 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   217
    self assert:(1.0 asQDouble = 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   218
    self assert:(1.0 asQDouble = 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   219
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   220
    self assert:(1 = 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   221
    self assert:(1 asQDouble = 1).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   222
    self assert:(1 asQDouble = 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   223
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   224
    self assert:(1 = 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   225
    self assert:(1.0 asQDouble = 1).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   226
    self assert:(1.0 asQDouble = 1 asQDouble).
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   227
1608
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   228
    self assert:(1.0 = 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   229
    self assert:(1 asQDouble = 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   230
    self assert:(1 asQDouble = 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   231
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   232
1608
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   233
    self deny:(1.0 = 1.1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   234
    self deny:(1.0 asQDouble = 1.1).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   235
    self deny:(1.0 asQDouble = 1.1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   236
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   237
    self deny:(1 = 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   238
    self deny:(1 asQDouble = 2).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   239
    self deny:(1 asQDouble = 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   240
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   241
    self deny:(1 = 2.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   242
    self deny:(1.0 asQDouble = 2).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   243
    self deny:(1.0 asQDouble = 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   244
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   245
    self deny:(2.0 = 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   246
    self deny:(2 asQDouble = 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   247
    self deny:(2 asQDouble = 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   248
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   249
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   250
1608
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   251
    self assert:(1.0 < 1.1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   252
    self assert:(1.0 asQDouble < 1.1).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   253
    self assert:(1.0 asQDouble < 1.1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   254
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   255
    self assert:(1 < 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   256
    self assert:(1 asQDouble < 2).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   257
    self assert:(1 asQDouble < 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   258
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   259
    self assert:(1 < 2.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   260
    self assert:(1.0 asQDouble < 2).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   261
    self assert:(1.0 asQDouble < 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   262
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   263
    self assert:(1.0 < 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   264
    self assert:(1 asQDouble < 2.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   265
    self assert:(1 asQDouble < 2.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   266
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   267
1608
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   268
    self deny:(1.0 < 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   269
    self deny:(1.0 asQDouble < 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   270
    self deny:(1.0 asQDouble < 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   271
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   272
    self deny:(1 < 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   273
    self deny:(1 asQDouble < 1).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   274
    self deny:(1 asQDouble < 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   275
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   276
    self deny:(1 < 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   277
    self deny:(1.0 asQDouble < 1).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   278
    self deny:(1.0 asQDouble < 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   279
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   280
    self deny:(1.0 < 1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   281
    self deny:(1 asQDouble < 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   282
    self deny:(1 asQDouble < 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   283
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   284
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   285
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   286
    self assert:(2.0 > 1.1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   287
    self assert:(2.0 asQDouble > 1.1).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   288
    self assert:(2.0 asQDouble > 1.1 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   289
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   290
    self assert:(3 > 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   291
    self assert:(3 asQDouble > 2).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   292
    self assert:(3 asQDouble > 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   293
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   294
    self assert:(3 > 2.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   295
    self assert:(3.0 asQDouble > 2).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   296
    self assert:(3.0 asQDouble > 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   297
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   298
    self assert:(3.0 > 2 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   299
    self assert:(3 asQDouble > 2.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   300
    self assert:(3 asQDouble > 2.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   301
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   302
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   303
    self deny:(1.0 > 3.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   304
    self deny:(1.0 asQDouble > 3.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   305
    self deny:(1.0 asQDouble > 3.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   306
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   307
    self deny:(1 > 3 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   308
    self deny:(1 asQDouble > 3).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   309
    self deny:(1 asQDouble > 3 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   310
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   311
    self deny:(1 > 3.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   312
    self deny:(1.0 asQDouble > 3).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   313
    self deny:(1.0 asQDouble > 3 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   314
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   315
    self deny:(1.0 > 3 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   316
    self deny:(1 asQDouble > 3.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   317
    self deny:(1 asQDouble > 3.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   318
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   319
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   320
    self assert:(1.0 <= 3.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   321
    self assert:(1.0 asQDouble <= 3.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   322
    self assert:(1.0 asQDouble <= 3.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   323
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   324
    self assert:(1.0 <= 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   325
    self assert:(1.0 asQDouble <= 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   326
    self assert:(1.0 asQDouble <= 1.0 asQDouble).
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   327
1608
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   328
    self assert:(2.0 >= 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   329
    self assert:(2.0 asQDouble >= 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   330
    self assert:(2.0 asQDouble >= 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   331
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   332
    self assert:(1.0 >= 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   333
    self assert:(1.0 asQDouble >= 1.0).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   334
    self assert:(1.0 asQDouble >= 1.0 asQDouble).
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   335
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   336
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   337
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   338
    self assert: ((1.0 asQDouble + 1e-40) > 1.0 asQDouble).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   339
    self assert: (1.0 asQDouble < (1.0 asQDouble + 1e-40)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   340
    self assert: (1.0 asQDouble < (1.0 asQDouble + 1e-80)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   341
    self assert: (1.0 asQDouble < (1.0 asQDouble + 1e-120)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   342
    self assert: (1.0 asQDouble < (1.0 asQDouble + 1e-300)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   343
    self assert: (1.0 asQDouble < (1.0 asQDouble + 1e-300)).
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   344
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   345
    self assert: ((1.0 asQDouble + 1e-40) > 1.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   346
    self assert: (1.0 < (1.0 asQDouble + 1e-40)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   347
    self assert: (1.0 < (1.0 asQDouble + 1e-80)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   348
    self assert: (1.0 < (1.0 asQDouble + 1e-120)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   349
    self assert: (1.0 < (1.0 asQDouble + 1e-300)).
2445
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   350
    self assert: (1.0 < (1.0 asQDouble + 1e-308)).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   351
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   352
    self assert: (1.0 asQDouble < (1.0 asQDouble + 1e-40) ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   353
    self assert: ((1.0 asQDouble + 1e-40) > 1.0 asQDouble ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   354
    self assert: ((1.0 asQDouble + 1e-80) > 1.0 asQDouble ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   355
    self assert: ((1.0 asQDouble + 1e-120) > 1.0 asQDouble ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   356
    self assert: ((1.0 asQDouble + 1e-300) > 1.0 asQDouble ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   357
    self assert: ((1.0 asQDouble + 1e-308) > 1.0 asQDouble ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   358
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   359
    self assert: ((1.0 asQDouble + 1e-40) > 1.0).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   360
    self assert: (1.0 < (1.0 asQDouble + 1e-40)).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   361
    self assert: (1.0 < (1.0 asQDouble + 1e-80)).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   362
    self assert: (1.0 < (1.0 asQDouble + 1e-120)).
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   363
    self assert: (1.0 < (1.0 asQDouble + 1e-300)).
2445
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   364
    self assert: (1.0 < (1.0 asQDouble + 1e-300)).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   365
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   366
    self assert: (1.0  < (1.0 asQDouble + 1e-40) ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   367
    self assert: ((1.0 asQDouble + 1e-40) > 1.0  ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   368
    self assert: ((1.0 asQDouble + 1e-80) > 1.0  ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   369
    self assert: ((1.0 asQDouble + 1e-120) > 1.0  ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   370
    self assert: ((1.0 asQDouble + 1e-300) > 1.0  ).
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   371
    self assert: ((1.0 asQDouble + 1e-308) > 1.0  ).
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   372
1619
75c3687a4f4d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
   373
    self assert: (1e10 asQDouble + 1.0) = 10000000001.0.
75c3687a4f4d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
   374
    "/ that's the problem with Floats...
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   375
    "/ (1e20 asQDouble + 1.0) ~= 100000000000000000001.0.
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   376
    "/ (1e20 + 1.0) - 1e20 ~= 1.0.
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   377
    self assert: (1e20 asQDouble + 1.0) - 1e20 = 1.0.
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   378
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   379
    "/ here the precision of QDOubles is no longer enough:
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   380
    "/ self assert:  1.0 asQDouble < (1.0 asQDouble + 1e-310).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   381
1608
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   382
    "
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   383
     self run:#test_03_subtract
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   384
     self new test_03_subtract
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   385
    "
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   386
be5ee2de7d8b #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1607
diff changeset
   387
    "Created: / 13-06-2017 / 17:11:37 / cg"
1619
75c3687a4f4d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1618
diff changeset
   388
    "Modified (comment): / 20-06-2017 / 09:18:50 / cg"
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   389
    "Modified: / 05-06-2019 / 20:16:21 / Claus Gittinger"
1614
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   390
!
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   391
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   392
test_05_multiply
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   393
    |q1 q2 p|
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   394
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   395
    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
   396
    p := 2.0 * q1.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   397
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   398
    self assert:(p d0 = 6.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   399
    self assert:(p d1 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   400
    self assert:(p d2 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   401
    self assert:(p d3 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   402
    self assert:(p = 6.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   403
    self assert:(6.0 = p).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   404
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   405
    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
   406
    p := q1 * 3.0.
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   407
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   408
    self assert:(p d0 = 6.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   409
    self assert:(p d1 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   410
    self assert:(p d2 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   411
    self assert:(p d3 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   412
    self assert:(p = 6.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   413
    self assert:(6.0 = p).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   414
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   415
    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
   416
    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
   417
    p := q1 * q2.
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   418
1614
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   419
    self assert:(p d0 = 6.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   420
    self assert:(p d1 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   421
    self assert:(p d2 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   422
    self assert:(p d3 = 0.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   423
    self assert:(p = 6.0).
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   424
    self assert:(6.0 = p).
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   425
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   426
    "/ the 1 is not forgotten!!
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   427
    q1 := 1 asQDouble + 1e40.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   428
    q2 := 2.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   429
    p := q1 * q2.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   430
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   431
    self assert:(p d0 = 2e40).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   432
    self assert:(p d1 = 2.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   433
    self assert:(p d2 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   434
    self assert:(p d3 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   435
    self assert:(p > 2e40).
1751
b025e8468c85 *** empty log message ***
sr
parents: 1627
diff changeset
   436
    self assert:(p - 2e40) = 2.0.
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   437
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   438
    "/ nothing is forgotten!!
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   439
    q1 := 1 asQDouble + 1e40 + 1e120.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   440
    q2 := 2.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   441
    p := q1 * q2.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   442
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   443
    self assert:(p d0 = 2e120).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   444
    self assert:(p d1 = 2e40).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   445
    self assert:(p d2 = 2.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   446
    self assert:(p d3 = 0.0).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   447
    self assert:(p > 2e120).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   448
    self assert:(p > (2e120 asQDouble + 2)).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   449
    self assert:(p > (2e120 asQDouble + 1e40)).
1751
b025e8468c85 *** empty log message ***
sr
parents: 1627
diff changeset
   450
    self assert:(p - 2e120) = (2 asQDouble + 2e40).
b025e8468c85 *** empty log message ***
sr
parents: 1627
diff changeset
   451
    self assert:(p - 2e120 - 2e40) = 2.0.
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   452
1614
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   453
    "
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   454
     self run:#test_05_multiply
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   455
     self new test_05_multiply
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   456
    "
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   457
ead11e8f7913 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   458
    "Created: / 19-06-2017 / 16:58:29 / cg"
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   459
    "Modified (comment): / 20-06-2017 / 07:42:52 / cg"
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   460
    "Modified: / 05-06-2019 / 20:16:30 / Claus Gittinger"
1616
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   461
!
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   462
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   463
test_06_exp
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   464
    |f1 q1|
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   465
1623
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   466
    f1 := 2.0 exp.
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   467
    q1 := 2.0 asQDouble exp.
2435
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   468
    self assert:(q1 d0 - f1) abs < 0.00000001.
1616
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   469
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   470
    "/ the first 113 digits are (wolfram):
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   471
    "/    7.3890560989306502272304274605750078131803155705518473240871278225225737960790577633843124850791217947737531612654...
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   472
    "/ 2.0 exp
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   473
    "/    7.38905609893065
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   474
    "/ 2.0QD exp
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   475
    "/    7.389056098930650227230427460575
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   476
    "/ 2.0QD exp printfPrintString:'%.60f'
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   477
    "/    7.389056098930650227230427460575007813180315570551847324087128
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   478
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   479
    f1 := 3.0 exp.
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   480
    q1 := 3.0 asQDouble exp.
2435
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   481
    self assert:(q1 d0 - f1) abs < 0.00000001.
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   482
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   483
    "/ the first 113 digits are (wolfram):
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   484
    "/    20.0855369231876677409285296545817178969879078385541501443789342296988458780919737312044971602530177021536076158519...
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   485
    "/ 3.0 exp
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   486
    "/    20.0855369231877
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   487
    "/ 3.0QD exp
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   488
    "/    20.08553692318766774092852965458
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   489
    "/ 3.0QD exp printfPrintString:'%.60f'
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   490
    "/    20.085536923187667740928529654581717896987907838554150144378934
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   491
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   492
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   493
    f1 := 0.5 exp.
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   494
    q1 := 0.5 asQDouble exp.
2435
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   495
    self assert:(q1 d0 - f1) abs < 0.00000001.
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   496
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   497
    "/ the first digits are (wolfram):
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   498
    "/    1.648721270700128146848650787814163571653776100710148011575...
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   499
    "/ 0.5 exp
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   500
    "/    1.64872127070013
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   501
    "/ 0.5QD exp
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   502
    "/    1.648721270700128146848650787814
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   503
    "/ 0.5QD exp printfPrintString:'%.60f'
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   504
    "/    1.648721270700128146848650787814163571653776100710148011575079
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   505
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   506
    f1 := -1.0 exp.
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   507
    q1 := -1.0 asQDouble exp.
2435
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   508
    self assert:(q1 d0 - f1) abs < 0.00000001.
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   509
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   510
    f1 := -3.0 exp.
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   511
    q1 := -3.0 asQDouble exp.
2436
ae3aaedd0b32 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2435
diff changeset
   512
    self assert:(q1 d0 - f1) abs < 0.00000001.
ae3aaedd0b32 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2435
diff changeset
   513
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   514
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   515
"/    1.0 exp  -> 2.71828182845905
2435
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   516
"/    1.0 asQDouble exp  2.718281828459045235360287471353
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   517
"/    1.0 exp asQDouble  2.718281828459045090795598298428
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   518
"/
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   519
"/    3.0 ln  -> 1.09861228866811
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   520
"/    3.0 asQDouble ln 8.148220079427205481478375773976
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   521
"/    3.0 ln asQDouble  1.098612288668109782108217586938
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   522
"/
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   523
"/    1.0 exp ln -> 1.0
2435
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   524
"/    1.0 exp ln asQDouble  -> 1.0
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   525
"/    1.0 asQDouble exp ln     6.316187310732210430808896199868
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   526
"/    1.0 exp asQDouble ln     6.316187310732210132396290848094
6c6844fd7701 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2434
diff changeset
   527
"/
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   528
"/    f1 := 100 exp asQDouble 2.68811714181614E+.
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   529
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   530
    f1 := 100 exp.
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   531
    q1 := 100 asQDouble exp.
2436
ae3aaedd0b32 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2435
diff changeset
   532
    "/ self assert:(q1 d0 - f1) abs < 0.00000001.
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   533
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   534
    "/ the first digits are (wolfram):
2445
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   535
    "/    2.688117141816135448412625551580013587361111877374192241519160861528028703490956491415887109721984571081167087... × 10^43
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   536
    "/ 100 exp
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   537
    "/    2.688117141816135448E+43
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   538
    "/ 100QD exp
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   539
    "/    2.6881171418161354 109477678826e43
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   540
    "/ 100QD exp printfPrintString:'%2.60g'
2434
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   541
    "/    2.688117141816135410947767882599577473393902466198400202846738e43'
38fddd1ebaf7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   542
1616
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   543
    "
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   544
     self run:#test_06_exp
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   545
     self new test_06_exp
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   546
    "
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   547
04f3c6561ee0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 1615
diff changeset
   548
    "Created: / 19-06-2017 / 17:58:08 / cg"
1623
047593c3208f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1620
diff changeset
   549
    "Modified (comment): / 21-06-2017 / 13:45:56 / cg"
2269
3ec7c31b9673 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   550
    "Modified: / 05-06-2019 / 20:16:35 / Claus Gittinger"
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   551
!
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   552
1627
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   553
test_06b_log10
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   554
    |q1 q2 d3a q3a d3b q3b q4 i|
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   555
2441
d32842601d64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 2440
diff changeset
   556
    "/ 5.5...e-18
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   557
    q1 := QDouble d0: 5.55111512312578E-18
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   558
		  d1: -3.08148791101958E-34
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   559
		  d2: 1.71056941445901E-50
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   560
		  d3: 0.0.
1627
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   561
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   562
    q2 := 10 / q1.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   563
    self assert:(q2 > 1e18).
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   564
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   565
    d3a := q2 asFloat ln.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   566
    self assert:(d3a isNaN not).
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   567
1627
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   568
    q3a := q2 ln.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   569
    self assert:(q3a isNaN not).
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   570
1627
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   571
    d3b := q2 asFloat log10.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   572
    self assert:(d3b isNaN not).
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   573
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   574
    q3b := q2 log10.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   575
    self assert:(q3b isNaN not).
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   576
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   577
    q4 := q3b floor.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   578
    i := q4 asInteger.
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   579
2441
d32842601d64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 2440
diff changeset
   580
    self assert:(1.0 asQDouble ln = 0.0).
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   581
    self assert:(QDouble e ln - 1.0) < (2*QDouble epsilon).
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   582
    self assert:(QDouble e squared ln - 2.0) < (2*QDouble epsilon).
2441
d32842601d64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 2440
diff changeset
   583
d32842601d64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 2440
diff changeset
   584
    self assert:(1.0 asQDouble log10 = 0.0).
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   585
    self assert:(10.0 asQDouble log10 - 1.0) < (2*QDouble epsilon).
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   586
    self assert:(10000.0 asQDouble log10 - 5.0) < (2*QDouble epsilon).
2441
d32842601d64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 2440
diff changeset
   587
    self assert:(1e20 asQDouble log10 - 20.0) < (2*QDouble epsilon).
d32842601d64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 2440
diff changeset
   588
    self assert:(1e-20 asQDouble log10 + 20.0) < (2*QDouble epsilon).
d32842601d64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 2440
diff changeset
   589
d32842601d64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 2440
diff changeset
   590
    "/ nope: too inaccurate
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   591
    "/ self assert:(1e-100 asQDouble log10 + 100.0) < (2*QDouble epsilon).
2441
d32842601d64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 2440
diff changeset
   592
d32842601d64 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 2440
diff changeset
   593
    "/ QDouble fmax abs log10 floor asInteger.
1627
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   594
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   595
    "
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   596
     self run:#test_06b_log10
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   597
     self new test_06b_log10
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   598
    "
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   599
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   600
    "Created: / 03-07-2017 / 10:31:53 / cg"
2270
960a8b13323c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
   601
    "Modified: / 05-06-2019 / 20:18:26 / Claus Gittinger"
1627
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   602
!
ad08ca4a7ee6 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1623
diff changeset
   603
2432
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   604
test_06c_exp
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   605
    |f1 q1 f2 q2 f3 q3|
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   606
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   607
    f1 := 3.0 ln.
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   608
    q1 := 3.0 ln asQDouble.
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   609
    self assert:(q1 - f1) abs < 0.0001.
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   610
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   611
    f2 := f1 negated.
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   612
    q2 := q1 negated.
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   613
    self assert:(q2 - f2) abs < 0.0001.
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   614
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   615
    f3 := f2 exp.
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   616
    q3 := q2 exp.
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   617
    self assert:(q3 - f3) abs < 0.0001.
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   618
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   619
    "
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   620
     self run:#test_06c_exp
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   621
     self new test_06c_exp
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   622
    "
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   623
!
79b0e704f29f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2419
diff changeset
   624
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   625
test_07_reading
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   626
    |q1 s|
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   627
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   628
    q1 := QDouble readFrom: '3.1415926535897'.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   629
    s := '%55.54f' printf:{ q1 }.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   630
    self assert:(s = '                                        3.1415926535897').
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   631
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   632
    q1 := QDouble readFrom: '3.141592653589793238462643383'.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   633
    s := '%55.54f' printf:{ q1 }.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   634
    self assert:(s = '                          3.141592653589793238462643383').
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   635
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   636
    q1 := QDouble readFrom: '3.141592653589793238462643383279502884197169399375105820'.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   637
    s := '%55.54f' printf:{ q1 }.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   638
    self assert:(s = '3.14159265358979323846264338327950288419716939937510582').
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   639
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   640
    "
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   641
     self run:#test_07_reading
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   642
     self new test_07_reading
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   643
    "
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   644
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   645
    "Created: / 19-06-2017 / 23:29:34 / cg"
2270
960a8b13323c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
   646
    "Modified: / 05-06-2019 / 20:18:51 / Claus Gittinger"
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   647
!
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   648
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   649
test_08_conversion
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   650
    |q i|
2195
864930fc306d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1751
diff changeset
   651
1617
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   652
    q := 1e10 asQDouble + 1.0.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   653
    i := q asInteger.
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   654
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   655
    self assert:(i = 10000000001).
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   656
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   657
    "
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   658
     self run:#test_08_conversion
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   659
     self new test_08_conversion
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   660
    "
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   661
92cc9694fd5e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 1616
diff changeset
   662
    "Created: / 20-06-2017 / 07:51:50 / cg"
2270
960a8b13323c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2269
diff changeset
   663
    "Modified: / 05-06-2019 / 20:18:48 / Claus Gittinger"
2417
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
   664
!
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
   665
2418
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   666
test_09_truncatingAndRounding
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   667
    self assert:(1.0 truncatedAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   668
    self assert:(1.0 asQDouble truncatedAsFloat = 1.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   669
    self assert:(1.0 asQDouble truncatedAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   670
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   671
    self assert:(1.1 truncatedAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   672
    self assert:(1.1 asQDouble truncatedAsFloat = 1.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   673
    self assert:(1.1 asQDouble truncatedAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   674
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   675
    self assert:(1.999 truncatedAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   676
    self assert:(1.999 asQDouble truncatedAsFloat = 1.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   677
    self assert:(1.999 asQDouble truncatedAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   678
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   679
    self assert:(-1.999 truncatedAsFloat = -1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   680
    self assert:(-1.999 asQDouble truncatedAsFloat = -1.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   681
    self assert:(-1.999 asQDouble truncatedAsFloat = -1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   682
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   683
    self assert:(1.0 truncated == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   684
    self assert:(1.0 asQDouble truncated == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   685
    self assert:(1.0 asQDouble truncated == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   686
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   687
    self assert:(1.1 truncated == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   688
    self assert:(1.1 asQDouble truncated == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   689
    self assert:(1.1 asQDouble truncated == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   690
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   691
    self assert:(1.999 truncated == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   692
    self assert:(1.999 asQDouble truncated == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   693
    self assert:(1.999 asQDouble truncated == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   694
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   695
    self assert:(-1.999 truncated == -1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   696
    self assert:(-1.999 asQDouble truncated == -1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   697
    self assert:(-1.999 asQDouble truncated == -1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   698
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   699
    "/ ---------
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   700
    self assert:(1.0 floorAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   701
    self assert:(1.0 asQDouble floorAsFloat = 1.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   702
    self assert:(1.0 asQDouble floorAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   703
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   704
    self assert:(1.1 floorAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   705
    self assert:(1.1 asQDouble floorAsFloat = 1.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   706
    self assert:(1.1 asQDouble floorAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   707
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   708
    self assert:(1.999 floorAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   709
    self assert:(1.999 asQDouble floorAsFloat = 1.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   710
    self assert:(1.999 asQDouble floorAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   711
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   712
    self assert:(-1.999 floorAsFloat = -2.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   713
    self assert:(-1.999 asQDouble floorAsFloat = -2.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   714
    self assert:(-1.999 asQDouble floorAsFloat = -2.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   715
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   716
    self assert:(1.0 floor == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   717
    self assert:(1.0 asQDouble floor == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   718
    self assert:(1.0 asQDouble floor == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   719
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   720
    self assert:(1.1 floor == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   721
    self assert:(1.1 asQDouble floor == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   722
    self assert:(1.1 asQDouble floor == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   723
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   724
    self assert:(1.999 floor == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   725
    self assert:(1.999 asQDouble floor == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   726
    self assert:(1.999 asQDouble floor == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   727
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   728
    self assert:(-1.999 floor == -2).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   729
    self assert:(-1.999 asQDouble floor == -2).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   730
    self assert:(-1.999 asQDouble floor == -2).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   731
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   732
    "/ -------
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   733
    self assert:(1.0 ceilingAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   734
    self assert:(1.0 asQDouble ceilingAsFloat = 1.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   735
    self assert:(1.0 asQDouble ceilingAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   736
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   737
    self assert:(1.1 ceilingAsFloat = 2.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   738
    self assert:(1.1 asQDouble ceilingAsFloat = 2.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   739
    self assert:(1.1 asQDouble ceilingAsFloat = 2.0).
2417
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
   740
2418
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   741
    self assert:(1.999 ceilingAsFloat = 2.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   742
    self assert:(1.999 asQDouble ceilingAsFloat = 2.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   743
    self assert:(1.999 asQDouble ceilingAsFloat = 2.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   744
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   745
    self assert:(-1.999 ceilingAsFloat = -1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   746
    self assert:(-1.999 asQDouble ceilingAsFloat = -1.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   747
    self assert:(-1.999 asQDouble ceilingAsFloat = -1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   748
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   749
    self assert:(1.0 ceiling == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   750
    self assert:(1.0 asQDouble ceiling == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   751
    self assert:(1.0 asQDouble ceiling == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   752
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   753
    self assert:(1.1 ceiling == 2).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   754
    self assert:(1.1 asQDouble ceiling == 2).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   755
    self assert:(1.1 asQDouble ceiling == 2).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   756
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   757
    self assert:(1.999 ceiling == 2).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   758
    self assert:(1.999 asQDouble ceiling == 2).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   759
    self assert:(1.999 asQDouble ceiling == 2).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   760
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   761
    self assert:(-1.999 ceiling == -1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   762
    self assert:(-1.999 asQDouble ceiling == -1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   763
    self assert:(-1.999 asQDouble ceiling == -1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   764
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   765
    "/ ---------
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   766
    self assert:(1.0 roundedAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   767
    self assert:(1.0 asQDouble roundedAsFloat = 1.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   768
    self assert:(1.0 asQDouble roundedAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   769
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   770
    self assert:(1.1 roundedAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   771
    self assert:(1.1 asQDouble roundedAsFloat = 1.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   772
    self assert:(1.1 asQDouble roundedAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   773
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   774
    self assert:(1.999 roundedAsFloat = 2.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   775
    self assert:(1.999 asQDouble roundedAsFloat = 2.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   776
    self assert:(1.999 asQDouble roundedAsFloat = 2.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   777
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   778
    self assert:(1.499 roundedAsFloat = 1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   779
    self assert:(1.499 asQDouble roundedAsFloat = 1.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   780
    self assert:(1.499 asQDouble roundedAsFloat = 1.0).
2417
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
   781
2418
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   782
    self assert:(1.5 roundedAsFloat = 2.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   783
    self assert:(1.5 asQDouble roundedAsFloat = 2.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   784
    self assert:(1.5 asQDouble roundedAsFloat = 2.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   785
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   786
    self assert:(-1.999 roundedAsFloat = -2.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   787
    self assert:(-1.999 asQDouble roundedAsFloat = -2.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   788
    self assert:(-1.999 asQDouble roundedAsFloat = -2.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   789
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   790
    self assert:(-1.499 roundedAsFloat = -1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   791
    self assert:(-1.499 asQDouble roundedAsFloat = -1.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   792
    self assert:(-1.499 asQDouble roundedAsFloat = -1.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   793
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   794
    self assert:(-1.5 roundedAsFloat = -2.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   795
    self assert:(-1.5 asQDouble roundedAsFloat = -2.0 asQDouble).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   796
    self assert:(-1.5 asQDouble roundedAsFloat = -2.0).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   797
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   798
    self assert:(1.0 rounded == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   799
    self assert:(1.0 asQDouble rounded == 1).
2417
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
   800
2418
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   801
    self assert:(1.1 rounded == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   802
    self assert:(1.1 asQDouble rounded == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   803
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   804
    self assert:(1.999 rounded == 2).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   805
    self assert:(1.999 asQDouble rounded == 2).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   806
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   807
    self assert:(1.499 rounded == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   808
    self assert:(1.499 asQDouble rounded == 1).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   809
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   810
    self assert:(1.5 rounded == 2).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   811
    self assert:(1.5 asQDouble rounded == 2).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   812
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   813
    self assert:(-1.999 rounded == -2).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   814
    self assert:(-1.999 asQDouble rounded == -2).
2454
7d1bfada3e52 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2445
diff changeset
   815
7d1bfada3e52 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2445
diff changeset
   816
    self assert:((-1.6 roundTo:0.5) = -1.5).
7d1bfada3e52 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2445
diff changeset
   817
    self assert:((-1.6 asQDouble roundTo:0.5) = -1.5).
7d1bfada3e52 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2445
diff changeset
   818
    self assert:((-1.6 asQDouble roundTo:0.5) = -1.5 asQDouble).
2418
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   819
2417
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
   820
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
   821
    "
2418
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   822
     self run:#test_09_truncatingAndRounding
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   823
     self new test_09_truncatingAndRounding
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   824
    "
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   825
!
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   826
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   827
test_10_printing
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   828
    "/ 1.0001 asQDouble printString.
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   829
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   830
    self assert:(1.0 asQDouble printString = 1.0 printString).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   831
    self assert:(1.0 asQDouble printString = '1.0').
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   832
    self assert:(-1.0 asQDouble printString = -1.0 printString).
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   833
    self assert:(-1.0 asQDouble printString = '-1.0').
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   834
2436
ae3aaedd0b32 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2435
diff changeset
   835
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   836
    "/ self assert:(1.125QD printString = 1.125 printString).
2436
ae3aaedd0b32 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2435
diff changeset
   837
    self assert:(1.125 asQDouble printString = '1.125').
ae3aaedd0b32 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2435
diff changeset
   838
    self assert:(-1.125 asQDouble printString = -1.125 printString).
ae3aaedd0b32 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2435
diff changeset
   839
    self assert:(-1.125 asQDouble printString = '-1.125').
ae3aaedd0b32 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2435
diff changeset
   840
2418
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   841
    "/ loose bits in double prec.: (1e10 + 1) - 1e10  -> 1.0
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   842
    "/ loose bits in double prec.: (1e20 + 1) - 1e20  -> 0.0
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   843
    self assert:((1e20 asQDouble + 1) - 1e20) = 1.0.
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   844
    self assert:(((1e20 asQDouble + 1) - 1e20) printString = '1.0').
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   845
    self assert:((1e40 asQDouble + 1) - 1e40) = 1.0.
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   846
    self assert:(((1e40 asQDouble + 1) - 1e40) printString = '1.0').
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   847
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   848
    self assert:((1e40 asQDouble + 1 + 1e-40) - 1e40 - 1) = 1e-40.
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   849
    self assert:((1e40 asQDouble + 1 + 1e-40) + 1e-40 - 1e40 - 1) = 2e-40.
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   850
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   851
    "
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   852
     self run:#test_10_printing
187b80d0dd61 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   853
     self new test_10_printing
2417
6821e4990968 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
   854
    "
2439
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   855
!
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   856
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   857
test_11a_pi
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   858
    "/ Machin's Formula for Pi pi / 4  =  4 arctan(1/5) - arctan(1/239)
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   859
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   860
    | at1_5 at1_239 pi_4 pi err|
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   861
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   862
    at1_5 := (1 asQDouble / 5) arcTan.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   863
    at1_239 := (1 asQDouble / 239) arcTan.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   864
    pi_4 := (at1_5 * 4) - at1_239.
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   865
    pi := pi_4 * 4.
2439
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   866
    err := QDouble pi - pi.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   867
    self assert:(err < (8 * QDouble epsilon)).
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   868
!
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   869
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   870
test_11b_pi
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   871
    "/ Salamin-Brent Quadratic Formula for Pi
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   872
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   873
    | max_iter a b s m a_new b_new p_old pi err|
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   874
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   875
    max_iter := 6.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   876
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   877
    a := 1.0 asQDouble.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   878
    b := 0.5 asQDouble sqrt.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   879
    s := 0.5 asQDouble.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   880
    m := 1.0 asQDouble.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   881
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   882
    pi := 2.0 asQDouble * a squared / s.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   883
    1 to:max_iter do:[:i |
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   884
	m := m * 2.
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   885
	a_new := 0.5 * (a+b).
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   886
	b_new := a * b.
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   887
	s := s - (m * (a_new squared - b_new)).
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   888
	a := a_new.
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   889
	b := b_new sqrt.
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   890
	p_old := pi.
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   891
	pi := 2 * a squared / s.
2439
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   892
    ].
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   893
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   894
    err := QDouble pi - pi.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   895
    self assert:(err < (8 * QDouble epsilon)).
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   896
!
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   897
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   898
test_12_e
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   899
    "/ Taylor for e
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   900
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   901
    | e t n i err|
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   902
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   903
    e := 2.0 asQDouble.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   904
    t := 1.0 asQDouble.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   905
    n := 1.0.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   906
    i := 0.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   907
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   908
    [t > QDouble epsilon] whileTrue:[
2442
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   909
	i := i + 1.
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   910
	n := n + 1.0.
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   911
	t := t / n.
31b4f594212b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2441
diff changeset
   912
	e := e + t.
2439
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   913
    ].
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   914
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   915
    err := QDouble e - e.
fb81e7ceb6b2 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2436
diff changeset
   916
    self assert:(err < (8 * QDouble epsilon)).
1606
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   917
! !
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   918
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   919
!QDoubleTests class methodsFor:'documentation'!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   920
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   921
version
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   922
    ^ '$Header$'
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   923
!
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   924
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   925
version_CVS
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   926
    ^ '$Header$'
148c8253d741 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   927
! !
2445
89e91f4ded0b #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2442
diff changeset
   928