What is permissable with HUGE_VAL

Ray Butterworth rbutterworth at watmath.waterloo.edu
Fri Jul 20 06:49:33 AEST 1990


If I remember the discussion about this from a year or two ago,
there was nothing in the standard indicating what HUGE_VAL needed
to be, other than positive.
i.e.  there is no reason (other than the obvious sillyness) that
an implementation can't define HUGE_VAL as 5.2.

If you think no one would be silly,
consider the BSD definition of HUGE in their <math.h>:

    #define VALUE (4.15383748682786205e34 * 4096)
    
    /* from <math.h> */
    #define HUGE    1.701411733192644270e38
    
    main() {
        auto double huge = HUGE;
        auto double value = VALUE;
    
        if (value > huge)
            printf("value is bigger than huge\n");
        if (value < huge)
            printf("value is less than huge\n");
    }

Because of the nature of floating point it wouldn't be unreasonable
for both conditions to evaluate true, but in this case only the
first prints.  And if you look at the bits in the two variables
you'll see that value really is bigger than huge.



More information about the Comp.std.c mailing list