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