| T.R | Title | User | Personal Name
 | Date | Lines | 
|---|
| 9378.1 | with -ieee, HUGE_VAL is +infinity | HYDRA::NEWMAN | Chuck Newman, 508/467-5499 (DTN 297), MRO1-3/F26 | Thu Apr 03 1997 09:58 | 9 | 
|  | My analysis (from looking at the .lis file) shows that when compiled
with -ieee, HUGE_VAL is +infinity (0x7ff0000000000000).
The compiler does the assignment correctly, but issues a warning that the
value isn't a valid number.
If they want the largest valid number, use DBL_MAX instead of HUGE_VAL.
								-- Chuck Newman
 | 
| 9378.2 | HUGE_VAL is +Infinity in -ieee mode | SUBPAC::FARICELLI |  | Thu Apr 03 1997 10:08 | 14 | 
|  | 
   Apparently the author of math.h intended for HUGE_VAL to be +Infinity
   when compiled in full ieee floating point mode; and the maximum
   finite double value if not.
   One way to get a +Infinity is to use a number larger than the
   maximum (1.8e308 will do this), but this makes the compiler issue
   a warning about exceeding the range of a double, even in
   -ieee_with_no_inexact (-ieee) mode. Should it?
   If you want the values of the maximum finite for double/float,
   see /usr/include/float.h (FLT_MAX, DBL_MAX).
   -- John Faricelli
 | 
| 9378.3 | Fixed in Steel | SMURF::GAF | Jerry Feldman, Unix Dev. Environment, DTN:381-2970 | Thu Apr 03 1997 16:11 | 20 | 
|  |     HUGE_VAL is required to be +Infinity in IEEE mode and DBL_MAX when not
    in IEEE mode. The compiler warning has been with us since day 1 (eg.
    Silver SSB). 
    
    In Steel, I change HUGE_VAL to point to the libc infinity value.
    #if defined(_IEEE_FP)
    extern  unsigned   int __DINFINITY[2];
    #	define HUGE_VAL (*((double *) (__DINFINITY)))
    #else
    #	define HUGE_VAL 1.797693134862315708e308
    #endif
    
    This will suppress the warning, but could cause compilation errors in
    some programs that initialize variables to HUGE_VAL. 
    
    In IEEE mode, all math functions that return HUGE_VAL return +/-
    infinity.
    
    Both the old C compiler, CFE, and the new C compiler, DECC, issue the
    warning. 
 | 
| 9378.4 |  | VESPER::VESPER | OpenGL Alpha Geek | Thu Apr 03 1997 16:36 | 17 | 
|  | >    In Steel, I change HUGE_VAL to point to the libc infinity value.
>    #if defined(_IEEE_FP)
>    extern  unsigned   int __DINFINITY[2];
>    #	define HUGE_VAL (*((double *) (__DINFINITY)))
>    #else
>    #	define HUGE_VAL 1.797693134862315708e308
>    #endif
>    
>    This will suppress the warning, but could cause compilation errors in
>    some programs that initialize variables to HUGE_VAL. 
Ouch!
Correct according to the standard (``positive double expression''), but
I'd still rather see a constant expression.
Andy V
 | 
| 9378.5 |  | SMURF::GAF | Jerry Feldman, Unix Dev. Environment, DTN:381-2970 | Fri Apr 04 1997 14:01 | 3 | 
|  |     re: .4
    Unfortunately, there is no way to put a constant in there and not have
    a compiler warning. Both CFE and DECC will generate a warning. 
 | 
| 9378.6 |  | RDGENG::CHAMBERLIN | Danger! Do not Reverse Polarity | Mon Apr 07 1997 05:01 | 10 | 
|  | Thanks for the discussion - I didn't expect a simple query to generate so much!
re .3 and .4, 
Personally I think I'd rather see a warning than have unexpailned errors later
on, but I guess we have to stick with the standards.
What do other suppliers do in this case?
/Ian 
 | 
| 9378.7 | AIX, SUNOS, HP | SMURF::GAF | Jerry Feldman, Unix Dev. Environment, DTN:381-2970 | Mon Apr 07 1997 11:01 | 16 | 
|  |     IBM AIX references a double value:
    #ifdef _ANSI_C_SOURCE
    
    extern  unsigned _DBLINF[2];
    
    #define HUGE_VAL (*((double *)(_DBLINF)))
    
    
    --------------------
    SunOS:
    #define HUGE_VAL __huge_val._d
    
    --------------------
    HP_UX uses a constant equivalent to the MAX_DOUBLE.
    
    
 |