🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #1311

Re: cc problem and cure: comparison among doubles can produce wrong results

#1311
From: Mark Wagner
Date: Fri, 06 Nov 1992 00:57
28 lines
1521 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.
> 
> 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
Technical Details
Message-ID: <5774@rosie.NeXT.COM>
Path: arc1-ca.pugleaf.net!sparky!uunet!rosie!NeXT.COM
References: <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: <5774@rosie.NeXT.COM>
Date: 6 Nov 92 00:57:13 GMT
References: <1ccm61INNhoq@agate.berkeley.edu>
Sender: news@NeXT.COM
Lines: 28