floating point constants
Walter Murray
walter at hpclwjm.HP.COM
Fri Jul 28 05:13:38 AEST 1989
>Is this a valid C program? gcc 1.35 handles it fine on a sun386i --
>everything else I've tried won't compile these odd constants.
>/* This should print out
> inf
> -inf
> NaN
>*/
>
>main()
>{
> printf("%f\n", 1.0/0.0);
> printf("%f\n", -1.0/0.0);
> printf("%f\n", 0.0/0.0);
>}
In our compiler (HP 9000 Series 800) we evaluate these expressions
at compile time, produce a warning, and store the appropriate
bit patterns for +/- infinity and NaN. That seemed to be the thing
to do to conform with the spirit of IEEE 754. Note, however, that
there is no standard for what these numbers look like when formatted
with "%f".
Walter Murray
----------
More information about the Comp.lang.c
mailing list