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