HUGE

Tim Hall tjh at bucrf11.bu.edu
Thu Jan 17 11:19:17 AEST 1991


The following pertains to PI's and 4D/2xx machines running 3.3.1...

Awhile ago I growled about setting a float value to "HUGE" and then
testing to see if that float value == HUGE and the result would be
not true.  After awhile I thought about it and figured I'd been dumb
in assigning HUGE to a float (I use it as a sort of "NULL" float value)
and I should attenuate HUGE and then life will be good.  No such luck.

The following line is from math.h
#define HUGE            3.40282347e+38  /*max decimal value of a "float" */
                                                                  ^^^^^

The following code demonstrates my problem.....

#include <stdio.h>
#include <math.h>

#define NOVALUE ((float)(HUGE * 0.001))
/* Surely this will produce a  ^^^^^^ valid float value! (Ha) */

main( )
{
        float a;

        a = NOVALUE;
        printf( "%f %f\n", NOVALUE, a ); /* They look exactly the same! */
        if ( a == NOVALUE )              /* But noooooooooooooooooooooo */
                printf( "Equal\n" );
        else
                printf( "Not Equal\n" );

}

So the final question is - is it me?  Shouldn't this work?  It used to.

-- 
-Tim Hall
tjh at bu-pub.bu.edu

GO BU! BEAT BC!



More information about the Comp.sys.sgi mailing list