#BUGFIX by stefan
class: RegressionTests::FloatTest
removed: #actualPrecisionOf:
changed: #test00_Precision
class: RegressionTests::FloatTest class
added: #actualPrecisionOf:
--- a/RegressionTests__FloatTest.st Tue May 29 16:02:27 2018 +0200
+++ b/RegressionTests__FloatTest.st Fri Jun 15 15:44:59 2018 +0200
@@ -12,29 +12,36 @@
!
-!FloatTest methodsFor:'helpers'!
+!FloatTest class methodsFor:'helpers'!
actualPrecisionOf:aFloatClass
"get the actual number of valid bits in the mantissa.
This does a real test (i.e. does not believe the compiled-in ifdefs)"
- |one x count two|
+ |one x count|
+
+
+"/ For LongFloat the worng value 53 is returned!!
+"/ See: https://sourceforge.net/p/mingw-w64/bugs/678/
+"/ Fix it here with:
+"/%{
+"/ __asm__ ("fninit");
+"/%}.
one := aFloatClass unity. "/ 1.0 in this class
- two := one coerce:2.0.
x := one.
count := 0.
[one + x > one] whileTrue:[
- x := x / two.
- count := count + 1.
+ x := x / 2.
+ count := count + 1.
].
^ count
"
- self basicNew actualPrecisionOf:ShortFloat
- self basicNew actualPrecisionOf:Float
- self basicNew actualPrecisionOf:LongFloat
+ self actualPrecisionOf:ShortFloat
+ self actualPrecisionOf:Float
+ self actualPrecisionOf:LongFloat
"
! !
@@ -45,12 +52,12 @@
|a b|
- self assert:( (a := Float precision) = (b := self actualPrecisionOf:Float))
- description:('Float precision: %1 ~~ actual: %2' bindWith:a with:b).
- self assert:( (a := ShortFloat precision) = (b := self actualPrecisionOf:ShortFloat))
- description:('ShortFloat precision: %1 ~~ actual: %2' bindWith:a with:b).
- self assert:( (a := LongFloat precision) = (b := self actualPrecisionOf:LongFloat))
- description:('LongFloat precision: %1 ~~ actual: %2' bindWith:a with:b).
+ self assert:( (a := Float precision) = (b := self class actualPrecisionOf:Float))
+ description:('Float precision: %1 ~~ actual: %2' bindWith:a with:b).
+ self assert:( (a := ShortFloat precision) = (b := self class actualPrecisionOf:ShortFloat))
+ description:('ShortFloat precision: %1 ~~ actual: %2' bindWith:a with:b).
+ self assert:( (a := LongFloat precision) = (b := self class actualPrecisionOf:LongFloat))
+ description:('LongFloat precision: %1 ~~ actual: %2' bindWith:a with:b).
"
self basicNew test00_Precision