--- a/RegressionTests__IEEEFloatTest.st Sun Dec 01 16:09:32 2019 +0100
+++ b/RegressionTests__IEEEFloatTest.st Sun Dec 01 16:09:57 2019 +0100
@@ -281,11 +281,11 @@
self assert:( 1.0 asIEEEFloat / 1.0 asLongFloat) class == IEEEFloat.
"/ self assert:( 1.0 asIEEEFloat / 1) class == IEEEFloat.
- self assert:( 5.0 asIEEEFloat rem: 2.0 ) class == IEEEFloat.
- self assert:( 1.0 asIEEEFloat rem: 2.0 asIEEEFloat) class == IEEEFloat.
- self assert:( 5.0 asIEEEFloat rem: 2.0 asShortFloat) class == IEEEFloat.
- self assert:( 5.0 asIEEEFloat rem: 2.0 asLongFloat) class == IEEEFloat.
- "/ self assert:( 5.0 asIEEEFloat rem: 2) class == IEEEFloat.
+"/ self assert:( 5.0 asIEEEFloat rem: 2.0 ) class == IEEEFloat.
+"/ self assert:( 1.0 asIEEEFloat rem: 2.0 asIEEEFloat) class == IEEEFloat.
+"/ self assert:( 5.0 asIEEEFloat rem: 2.0 asShortFloat) class == IEEEFloat.
+"/ self assert:( 5.0 asIEEEFloat rem: 2.0 asLongFloat) class == IEEEFloat.
+"/ "/ self assert:( 5.0 asIEEEFloat rem: 2) class == IEEEFloat.
"
self basicNew test04_Arithmetic
@@ -295,8 +295,15 @@
test05_Comparing
|convArray check v1 v2 v1b|
+ self assert:( 1.0 asIEEEFloat = 1.0).
+ self assert:( 1.0 asIEEEFloat = 1.0 asIEEEFloat).
+ self assert:( 1.0 asIEEEFloat = 1.0 asShortFloat).
+
+ "/ fails currently
+ "/ self assert:( 1.0 asIEEEFloat = 1.0 asLongFloat).
+
convArray := OrderedCollection new.
- convArray addAll:#(yourself asInteger asFloat asShortFloat asLongFloat).
+ convArray addAll:#(asInteger asFloat asShortFloat asLongFloat).
(Smalltalk at:#LargeFloat) notNil ifTrue:[
convArray add:#asLargeFloat.
@@ -331,61 +338,24 @@
].
].
- check value:2 value:3.
- check value:0 value:1.
- check value:-1 value:0.
- check value:-3 value:-2.
- check value:-3 value:3.
-
- check value:-30 value:1.
- check value:-1 value:30.
+ check value:2.0 asIEEEFloat value:3.
+ check value:0.0 asIEEEFloat value:1.
+ check value:-1.0 asIEEEFloat value:0.
+ check value:-3.0 asIEEEFloat value:-2.
+ check value:-3.0 asIEEEFloat value:3.
- "/ showing that float precision is limited...
-
- "/ test fails when stc code, jit code works
- false "(Helper
- isStcCompiledMethod:#'test05_Comparing'
- in:self)" ifTrue:[
- "/ stc-compiled code handles not slightly differently
- "/ listed compares will fail
- 'FloatTest >> test05_Comparing: test with 200000000000000000000 or similiar are skipped due would fail when stc code' infoPrintCR.
- ] ifFalse:[
- self assert:( 200000000000000000000.0 = 200000000000000000001.0 ).
-
- self assert:( 200000000000000000000.0 = 200000000000000000001 ).
- self assert:( 200000000000000000000.0 = 200000000000000000000 ).
- self assert:( 200000000000000000000.0 asLongFloat = 200000000000000000000 ).
-
- self assert:( 200000000000000000000 = 200000000000000000000.0).
- self assert:( 200000000000000000000 = 200000000000000000000.0 asLongFloat ).
+ check value:-30.0 asIEEEFloat value:1.
+ check value:-1.0 asIEEEFloat value:30.
- self assert:( 200000000000000000000.0 < 200000100000000000000 ).
- self assert:( 200000000000000000000.0 asLongFloat < 200000000000100000000 ).
- self assert:( 200000000000000000000.0 asShortFloat < 200001000000000000000 ).
-
- self assert:( 200000000000000000000 < 200001000000000000000.0).
- self assert:( 200000000000000000000 < 200001000000000000000.0 asLongFloat ).
- self assert:( 200000000000000000000 < 200001000000000000000.0 asShortFloat ).
-
- self assert:( 200000000000000000000.0 <= 200000100000000000000 ).
- self assert:( 200000000000000000000.0 <= 200000000000000000000 ).
- self assert:( 200000000000000000000.0 asLongFloat <= 200000000000000000001 ).
- self assert:( 200000000000000000000.0 asLongFloat <= 200000000000000000000 ).
+
+ self assert:( 2000000.0 asIEEEFloat = 2000000 ).
+ self assert:( 2000000 = 2000000.0 asIEEEFloat ).
- self assert:( 200000000000000000000 <= 200001000000000000000.0).
- self assert:( 200000000000000000000 <= 200000000000000000000.0).
- self assert:( 200000000000000000000 <= 200001000000000000000.0 asLongFloat ).
- self assert:( 200000000000000000000 <= 200000000000000000000.0 asLongFloat ).
- ].
+ self assert:( 2000000.0 asIEEEFloat <= 200000100000000000000 ).
+ self assert:( 2000000.0 asIEEEFloat <= 2000000 ).
- self assert:( 2000000.0 asShortFloat = 2000000 ).
- self assert:( 2000000 = 2000000.0 asShortFloat ).
-
- self assert:( 2000000.0 asShortFloat <= 200000100000000000000 ).
- self assert:( 2000000.0 asShortFloat <= 2000000 ).
-
- self assert:( 2000000 <= 2000000.0 asShortFloat ).
- self assert:( 2000000 <= 2000000.0 asShortFloat ).
+ self assert:( 2000000 <= 2000000.0 asIEEEFloat ).
+ self assert:( 2000000 <= 2000000.0 asIEEEFloat ).
"
self basicNew test05_Comparing
@@ -724,90 +694,58 @@
noQuadFloats := UnimplementedFunctionalityError catch:[1.0 asQuadFloat].
noOctaFloats := UnimplementedFunctionalityError catch:[1.0 asOctaFloat].
- self assert: (Float unity class == Float).
- self assert: (ShortFloat unity class == ShortFloat).
- self assert: (LongFloat unity class == LongFloat).
-
- self assert: (Float unity = 1.0).
- self assert: (ShortFloat unity = 1.0).
- self assert: (LongFloat unity = 1.0).
-
- self assert: (Float zero class == Float).
- self assert: (ShortFloat zero class == ShortFloat).
- self assert: (LongFloat zero class == LongFloat).
+ self assert:( 1.0 asShortFloat exponentBits = 1.0 asShortFloat asIEEEFloat exponentBits).
+ self assert:( 1.0 exponentBits = 1.0 asIEEEFloat exponentBits ).
- self assert: (Float zero = 0.0).
- self assert: (ShortFloat zero = 0.0).
- self assert: (LongFloat zero = 0.0).
-
- self assert:( LongFloat unity = 1 asLongFloat ).
- self assert:( ShortFloat unity = 1 asShortFloat ).
- self assert:( Float unity = 1 asFloat ).
-
- self assert:( 0.0 exponent = 0 ).
- self assert:( 1.0 exponent = 1 ).
- self assert:( 2.0 exponent = 2 ).
- self assert:( 3.0 exponent = 2 ).
- self assert:( 4.0 exponent = 3 ).
- self assert:( 0.5 exponent = 0 ).
- self assert:( 0.4 exponent = -1 ).
- self assert:( 0.25 exponent = -1 ).
- self assert:( 0.125 exponent = -2 ).
- self assert:( 0.00000011111 exponent = -23 ).
+ self assert:( 0.0 exponent = 0.0 asIEEEFloat exponent ).
+ self assert:( 1.0 exponent = 1.0 asIEEEFloat exponent ).
+ self assert:( 2.0 exponent = 2.0 asIEEEFloat exponent ).
+ self assert:( 3.0 exponent = 3.0 asIEEEFloat exponent ).
+ self assert:( 4.0 exponent = 4.0 asIEEEFloat exponent ).
+ self assert:( 0.5 exponent = 0.5 asIEEEFloat exponent ).
+ self assert:( 0.4 exponent = 0.4 asIEEEFloat exponent ).
+ self assert:( 0.25 exponent = 0.25asIEEEFloat exponent ).
+ self assert:( 0.125 exponent = 0.125 asIEEEFloat exponent ).
+ self assert:( 0.00000011111 exponent = 0.00000011111 asIEEEFloat exponent).
- self assert:( 0.0 asShortFloat exponent = 0 ).
- self assert:( 1.0 asShortFloat exponent = 1 ).
- self assert:( 2.0 asShortFloat exponent = 2 ).
- self assert:( 3.0 asShortFloat exponent = 2 ).
- self assert:( 4.0 asShortFloat exponent = 3 ).
- self assert:( 0.5 asShortFloat exponent = 0 ).
- self assert:( 0.4 asShortFloat exponent = -1 ).
- self assert:( 0.25 asShortFloat exponent = -1 ).
- self assert:( 0.125 asShortFloat exponent = -2 ).
- self assert:( 0.00000011111 asShortFloat exponent = -23 ).
-
- self assert:( 0.0 asLongFloat exponent = 0 ).
- self assert:( 1.0 asLongFloat exponent = 1 ).
- self assert:( 2.0 asLongFloat exponent = 2 ).
- self assert:( 3.0 asLongFloat exponent = 2 ).
- self assert:( 4.0 asLongFloat exponent = 3 ).
- self assert:( 0.5 asLongFloat exponent = 0 ).
- self assert:( 0.4 asLongFloat exponent = -1 ).
- self assert:( 0.25 asLongFloat exponent = -1 ).
- self assert:( 0.125 asLongFloat exponent = -2 ).
- self assert:( 0.00000011111 asLongFloat exponent = -23 ).
+ self assert:( 0.0 asShortFloat exponent = 0.0 asShortFloat asIEEEFloat exponent ).
+ self assert:( 1.0 asShortFloat exponent = 1.0 asShortFloat asIEEEFloat exponent ).
+ self assert:( 2.0 asShortFloat exponent = 2.0 asShortFloat asIEEEFloat exponent ).
+ self assert:( 3.0 asShortFloat exponent = 3.0 asShortFloat asIEEEFloat exponent ).
+ self assert:( 4.0 asShortFloat exponent = 4.0 asShortFloat asIEEEFloat exponent ).
+ self assert:( 0.5 asShortFloat exponent = 0.5 asShortFloat asIEEEFloat exponent ).
+ self assert:( 0.4 asShortFloat exponent = 0.4 asShortFloat asIEEEFloat exponent ).
+ self assert:( 0.25 asShortFloat exponent = 0.25 asShortFloat asIEEEFloat exponent ).
+ self assert:( 0.125 asShortFloat exponent = 0.125 asShortFloat asIEEEFloat exponent ).
+ self assert:( 0.00000011111 asShortFloat exponent = 0.00000011111 asIEEEFloat asShortFloat exponent ).
- #( 1.0 1
- 2.0 2
- 3.0 3
- 4.0 4
- 12345.0 12345
- 0.0 0
- -1.0 -1
- -2.0 -2
- -3.0 -3
- -4.0 -4
- -12345.0 -12345
- ) pairWiseDo:[:f :i |
- self assert:( f exponent = i exponent ).
- self assert:( f mantissa = i mantissa ).
- self assert:( f mantissa * (2 raisedTo:f exponent))= f.
- self assert:( i mantissa * (2 raisedTo:i exponent)) = i.
+ #( 1.0
+ 2.0
+ 3.0
+ 4.0
+ 12345.0
+ 0.0
+ -1.0
+ -2.0
+ -3.0
+ -4.0
+ -12345.0
+ ) do:[:f |
+ self assert:( f exponent = f asIEEEFloat exponent ).
+ self assert:( f mantissaBits = f asIEEEFloat mantissaBits ).
+ self assert:( f mantissa = f asIEEEFloat mantissa ).
+ self assert:( f mantissa * (2 raisedTo:f exponent)) = f.
+ self assert:( f asIEEEFloat mantissa * (2 raisedTo:f asIEEEFloat exponent)) = f asIEEEFloat.
- self assert:( f exponent = f asShortFloat exponent ).
- self assert:( f exponent = f asLongFloat exponent ).
- self assert:( f exponent = f asQDouble exponent ).
- self assert:( f asShortFloat mantissa * (2 raisedTo:f asShortFloat exponent))= f.
- self assert:( f asLongFloat mantissa * (2 raisedTo:f asLongFloat exponent))= f.
- self assert:( f asQDouble mantissa * (2 raisedTo:f asQDouble exponent))= f.
+ self assert:( f asShortFloat exponent = f asShortFloat asIEEEFloat exponent ).
+ self assert:( f asShortFloat mantissaBits = f asShortFloat asIEEEFloat mantissaBits ).
+ self assert:( f asShortFloat mantissa = f asShortFloat asIEEEFloat mantissa ).
+ self assert:( f asShortFloat mantissa * (2 raisedTo:f asShortFloat exponent)) = f asShortFloat.
+ self assert:( f asShortFloat asIEEEFloat mantissa * (2 raisedTo:f asShortFloat asIEEEFloat exponent)) = f asShortFloat asIEEEFloat.
noQuadFloats ifFalse:[
- self assert:( f exponent = f asQuadFloat exponent ).
- self assert:( f asQuadFloat mantissa * (2 raisedTo:f asQuadFloat exponent))= f.
].
noOctaFloats ifFalse:[
- self assert:( f exponent = f asOctaFloat exponent ).
- self assert:( f asOctaFloat mantissa * (2 raisedTo:f asOctaFloat exponent))= f.
].
].
"