[squeakdev] Re: [ANN] Number comparison, hash, NaN, Point,
and other partially ordered sets
Tim Olson
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
> squeak).
> 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 doubleprecision rounding step after the multiply,
while ((a d2e * b d2e) e2d) performs an extendedprecision rounding
step after the multiply, then another doubleprecision rounding step in
the conversion back to doubleprecision. 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 doubleprecision instead of extendedprecision, but that does
not limit the exponent range to the doubleprecision range, so denormal
results may still be different.
 Tim Olson
More information about the Squeakdev
mailing list
