[squeak-dev] Re: [ANN] Number comparison, hash, NaN, Point,
and other partially ordered sets
tim_olson at att.net
Thu Jan 8 14:08:15 UTC 2009
On Jan 8, 2009, at 2:19 AM, Nicolas Cellier wrote:
> Let's compute (a*b*c) where a,b,c are double precision (Float in
> Let selectors:
> - d2e mean (convert double to extended)
> - e2d mean (convert extended to double)
> For a double d, (d d2e e2d = d) is always true
> For an extended e, (e e2d d2e = e) might be false because some bits
> are lost.
> Unoptimized Smalltalk does:
> ((a d2e * b d2e) e2d d2e * c d2e) e2d.
> which should - thanks to IEEE 754 - be strictly equivalent to:
> (a * b) * c.
Unfortunately, this is not necessarily so, because of the extra
rounding steps involved:
(a * b) performs a double-precision rounding step after the multiply,
while ((a d2e * b d2e) e2d) performs an extended-precision rounding
step after the multiply, then another double-precision rounding step in
the conversion back to double-precision. This will result in a
difference in the final values in many cases.
There is a mode bit in x86 to cause the intermediate rounding to be
done with double-precision instead of extended-precision, but that does
not limit the exponent range to the double-precision range, so denormal
results may still be different.
-- Tim Olson
More information about the Squeak-dev