Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.315.mcz==================== Summary ====================
Name: KernelTests-nice.315
Author: nice
Time: 30 October 2016, 8:48:23.261504 pm
UUID: c3bd3e4f-135b-45d8-bc65-122fc2be8f69
Ancestors: KernelTests-nice.314
Rewrite the timesTwoPower: gradual underflow test to make it both:
- more thorough
- less obscure (I hope...)
=============== Diff against KernelTests-nice.314 ===============
Item was changed:
----- Method: FloatTest>>testTimesTwoPowerGradualUnderflow (in category 'testing - arithmetic') -----
testTimesTwoPowerGradualUnderflow
"Here is a vicious case where timesTwoPower is inexact because it underflows.
And two consecutive inexact operations lead to a different result than a single one.
+ Typically expressed as multiple of Float fmin in base 2,
+ 2r1011*Float fmin shifted by -3 with round to nearest, tie to even mode:
+ -> round(1.011) -> 1.0 = fmin
+ But if first shifted by -2 then by -1:
+ -> round(10.11) -> 11.0 = 3*fmin
+ -> round(1.1) -> 10.0 = 2*fmin
+ Or first shifted by -1 then by -2:
+ -> round(101.1) -> 110.0 = 6*fmin
+ -> round(1.1) -> 10.0 = 2*fmin
+ A naive implementation that split the shift uncarefully might fail to handle such case correctly."
- A naive implementation might fail to handle such case correctly."
| f |
+ f := 2r1011 asFloat.
+ "scan the whole range of possible exponents for this significand"
+ Float fmin exponent + f exponent to: Float fmax exponent - f exponent
+ do:
+ [:exp |
+ | g |
+ g := f timesTwoPower: exp.
+ self assert: (g timesTwoPower: Float fmin exponent - g exponent) = Float fmin]!
- f := 3.0 reciprocal predecessor predecessor predecessor.
- self deny: ((f timesTwoPower: Float emin) timesTwoPower: -3) = (f timesTwoPower: Float emin - 3)!