IEEE floating point format

Karl Heuer karl at haddock.ima.isc.com
Sat Aug 12 04:07:43 AEST 1989


In article <152 at servio.UUCP> penneyj at servio.UUCP (D. Jason Penney) writes:
>note that with truncating underflow, it is possible to have two floating 
>point values X and Y such that X != Y and yet (X - Y) == 0.0, 
>thus vitiating such precautions as,
>	if (X == Y) error("zero divide"); else something = 1.0 / (X - Y);

I used to have similar problems with the SIMULA compiler on TOPS-10, which
apparently used fuzzy compare even against zero: (example in C notation)
	if (X < 0.0) error("neg sqrt"); else something = sqrt(X);
would die because -1.0E-20 was considered "equal" to zero rather than
negative, yet the sqrt() routine wasn't fooled.  What a pain to work around!

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint
(What's this doing in comp.lang.c?  Followups to comp.lang.misc.)



More information about the Comp.lang.c mailing list