Re: Standard Fortran Floating point behaviour

From: glen herrmannsfeldt (gah_at_ugcs.caltech.edu)
Date: 03/31/04


Date: Wed, 31 Mar 2004 20:07:42 GMT


(previously snipped question about floating point equality comparison)

Dmitri Kavetski wrote:
> If the comparison is carried out in a register with higher precision then it
> is conceivable (?) that the value of A can get padded with additional
> nonzero digits and negate the comparison. So I would like to know if
> floating point standards prescribe any particular behaviour in this respect.

Well, the standard can guarantee all it wants to, but it
is the actual hardware that counts in the end.

If the hardware has operations that add non-zero digits then that
is what you will get. All hardware I know of extends with zeros.
The problems in Fortran occur when mixing precision and expecting
non-zero numbers to compare. 0.2 does not equal 0.2D0, and
because of rounding might not even when converted to single
precision.

There have been discussions about probabilistic rounding, which
might include random digits on extending numbers. Zero might be
a special case, though. If any hardware implemented that, it
might also implement interval comparison so that numbers would
compare equal when they were close enough.

-- glen



Relevant Pages

  • Re: float bug? perl 5.8, DBI and oracle 10.2.0
    ... precision numbers in oracle, you've got 38 decimal digits to play ... and with minimal coaxing perl will handle them as ... digits from a 32 bit floating point number - I'll go out on a limb ... and hazard that one can expect 12 or so digits from a 64 bit floating ...
    (perl.dbi.users)
  • Re: Linear Algebra Challenge
    ... Since I'm using floating point, so I'll never be able to calculate one ... floating point math set to 99 digits. ... As close as I'm willing to wait if I use arbitrary precision. ... This mode is fast; when you select arbitry ...
    (comp.sys.hp48)
  • Re: Interesting math
    ... Floating point number represents a real number with 6 digits precision. ... Floating point numbers are denoted by the keyword float. ...
    (alt.usage.english)
  • Re: Motorized knee" on the mill works great now!
    ... I consider it (extra precision in registers) a bug, ... claimed the hardware got wrong. ... For floating point, it allows one to sum a large number of ...
    (rec.crafts.metalworking)
  • Re: Interesting math
    ... Floating point number represents a real number with 6 digits precision. ... Floating point numbers are denoted by the keyword float. ...
    (alt.usage.english)