Floating Point Expectations

Dik T. Winter dik at cwi.nl
Wed Jun 6 06:13:00 AEST 1990


Just a minor followup:
In article <MOSS.90Jun1104004 at ibis.cs.umass.edu> moss at cs.umass.edu writes:
 > Just a minor followup to the (45.0 / 100.0) == .45 question:
...
 >                                                                        One
 > *would* expect (50.0 / 100.0) == .50 since .50 *does* have an exact
 > representation in binary.

I would not bet my money on it.  If the evaluation of 50.0 / 100.0 is done
using the hardware operation(s) to do division the result may very well
not be exact.  Try on a Cray:  3.0/3.0, 5.0/5.0, 7.0/7.0 etc.  Some give
exactly 1, others do not.  (The Cray does not have division, but inversion
followed by multiplication.  And all those inverses are not exact.)  Still
worse, on a CDC 205 in double precision division by 2.0 need not be exact.
--
dik t. winter, cwi, amsterdam, nederland
dik at cwi.nl



More information about the Comp.unix.wizards mailing list