Here's a challenge for floating point lovers.

Doug Gwyn gwyn at smoke.brl.mil
Thu Jan 24 09:36:10 AEST 1991


In article <1991Jan22.180927.29232 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
>>Does ANSI X3.159 require the ability to define such a constant?
>No.  Nobody's come up with a good way of doing this that I know of,
>especially when portability is desired.

Presumably portability is not an issue for this application.  What some
implementors do is to initialize what amounts to a union type with the
proper bits then refer to the floating-point member of that union to get
the value interpreted properly with the proper floating type.  The
standard does NOT require that the values of the <float.h> macros be
CONSTANT expressions; in particular they may access external storage at
run time (contents of such a union, for example).  Note also that this
means that FLT_RADIX and other <float.h> macros must not be used in #if
expressions in strictly conforming programs.



More information about the Comp.lang.c mailing list