home *** CD-ROM | disk | FTP | other *** search
- Path: 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: <5774@rosie.NeXT.COM>
- Date: 6 Nov 92 00:57:13 GMT
- References: <1ccm61INNhoq@agate.berkeley.edu>
- Sender: news@NeXT.COM
- Lines: 28
-
- > > 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.
- >
- > Actually, it's worse than this. Sometimes floating point values can be
- > different depending on whether or not they've been in and out of
- > registers, etc. Moral: Use something like this:
- >
- 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
-