Floating point non-exactness

John Baldwin johnb at srchtec.UUCP
Thu Aug 2 07:47:07 AEST 1990


In article <1990Jul31.101803.852 at urz.unibas.ch> carlos at urz.unibas.ch writes:
>
>> Can you ensure that "fpcmp (a, b)" and "fpcmp (a-b, 0.0)" yield the same
           ^^^^^^[emphasis mine]
>> result when a and b are very close?
>
>Yes, if your fp system conforms IEEE Std. 754 due to the existence of 
>denormalized numbers.

Actually, it depends on what the previous writer means by "ensure."
If the code has to be portable, one can't rely on IEEE-754 representation
of floating point values, since that's NOT part of the C standard.

Portably, you should be able to "get away with" using the values built in
to <float.h> (a required part of the standard library) for the epsilon
of your floating point representation.  [Just in case this slipped past
anyone, epsilon is the smallest quantity "e" such that x + e > x]

-- 
John T. Baldwin                      |  johnb at srchtec.uucp
Search Technology, Inc.              |  johnb%srchtec.uucp at mathcs.emory.edu
standard disclaimer:                 |  ...uunet!samsung!emory!stiatl!srchtec..
opinions and mistakes purely my own. |  ...mailrus!gatech!stiatl!srchtec...



More information about the Comp.lang.c mailing list