Article View: comp.sys.next.programmer
Article #1312Re: cc problem and cure: comparison among doubles can produce wrong results
From: Mark Wagner
Date: Fri, 06 Nov 1992 01:01
Date: Fri, 06 Nov 1992 01:01
24 lines
1317 bytes
1317 bytes
> > However, given that the conversion
> > algorithm from external to internal format is the same, I would
> argue that
> > ALL instances of the SAME decimal value will result in the SAME
> binary
> > floating point value internally and can therefore be compared for
> equality
> > with impunity.
>
One can use the -ffloat-store option to "cure" this problem but at some
cost in terms of performance (depending, of course, on the application).
-ffloat-store
Don't store floating-point variables in registers.
This prevents undesirable excess precision due to the
floating registers keeping more precision than a double
is supposed to have.
For most programs, the excess precision does no harm,
but a few programs rely on the precise definition of
IEEE floating point. Use -ffloat-store for such pro-
grams.
mwagner@next.com
Technical Details
Message-ID:
<5775@rosie.NeXT.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!rosie!NeXT.COMReferences:
<1ccm61INNhoq@agate.berkeley.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!rosie!NeXT.COM From: Mark_Wagner@NeXT.COM (Mark Wagner) Newsgroups: comp.sys.next.programmer Subject: Re: cc problem and cure: comparison among doubles can produce wrong results Message-ID: <5775@rosie.NeXT.COM> Date: 6 Nov 92 01:01:35 GMT References: <1ccm61INNhoq@agate.berkeley.edu> Sender: news@NeXT.COM Lines: 24