Questions about NCEG

Andrew P. Mullhaupt amull at Morgan.COM
Thu May 31 13:10:15 AEST 1990


In article <1990May29.193451.6533 at twinsun.com>, eggert at twinsun.com (Paul Eggert) writes:
> There are ways to say the IEEE numbers in ANSI C + IEEE 754:
> 	#define infinity (1e300*1e300)
> This lets you say some things portably that you can't say with hex contants,

Will this work if the compiler supports IEEE extended format for 
constants? Or would this preclude ANSI C compliance? The constant
1e600 is not out of extended range. You might replace 1e300 in your
example by a larger number, but then what about the compilers which
_don't_ use extended? Both behaviors are permitted by IEEE arithmetic.

A conditional compilation solution is possible only if you can 
ensure that the appropriate symbol will be defined. Once you've
been reduced to that, you should use the hex constant method, on the
grounds that even on the same hardware, different compilers, or even
different preprocessors for the same compiler may handle the constant
arithmetic differently, but the floating point representation is 
less likely to change.

Later,
Andrew Mullhaupt



More information about the Comp.std.c mailing list