ANSI float.h

Doug Gwyn gwyn at smoke.BRL.MIL
Wed Jan 18 02:23:52 AEST 1989


In article <5186 at lynx.UUCP> m5 at lynx.UUCP (Mike McNally) writes:
>The new K&R almost-ANSI book has a little section in the back that describes 
>the contents (well, part of the contents, apparently) of <float.h>.  I am
>confused by some of the "minimum magnitude" values listed:

K&R2 in many instances replaced the pedantic wording of the proposed
ANSI Std X3.159 with simpler, although less precise, wording, presumably
in an attempt to be more readily understood by the book's target
readership.

The X3.159 definitions are, I think, correct.  K&R2 is misleading.
(Of course, so were earlier X3.159 drafts that K&R2 was based on.)

>FLT_EPSILON 1e-5        Isn't that kind of big?  With IEEE single-precision,
>                        the actual value according to the definition should
>                        be something like 5.4e-8.

The X3.159 definition of *_EPSILON is "the difference between 1.0 and
the least value greater than 1.0 that is representable in the given
floating point type".  FLT_EPSILON is required to be at most 1E-5.
The proper value for an implementation that also conforms to ANSI/IEEE
Std 754-1985 (which is NOT required by X3.159) would be 1.19209290E-07F.

>FLT_MIN     1e-37       Does this mean that an ANSI-compliant compiler
>                        does not need to supply negative float values
>                        beyond a negative itsy-bitsy value?  Does it
>                        make sense that coding x=-2.0 results in a 
>                        non-portable program?

The X3.159 definition of *_MIN is "minimum normalized positive floating-
point number".  FLT_MIN is required to be at most 1E-37.  The proper
value for IEEE 754 (NOT required by X3.159) would be 1.17549435E-38F.



More information about the Comp.lang.c mailing list