Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Re: HUGEVAL: benign compiler warning under -ieee?
       [not found] <35D24A66.97565B9A@netscape.com>
@ 1998-08-23  4:00 ` Stefan Schwarzer
  0 siblings, 0 replies; only message in thread
From: Stefan Schwarzer @ 1998-08-23  4:00 UTC (permalink / raw)


Wan-Teh Chang <wtc@netscape.com> wrote:
: Consider this test program:
: --- begin foo_hugeval.c ---
: #include <math.h>

:     d = HUGE_VAL;

: If I compile it with the -ieee flag, I get a compiler warning:
: % cc -ieee foo_hugeval.c
: cc: Warning: foo_hugeval.c, line 7: In this statement, floating point
: overflow
: occurs in evaluating the expression "1.8e308".
:     d = HUGEVAL;
: ________^

: Is this compiler warning benign?  If so, is there a #pragma or compiler
: flag I can use to suppress this warning?

The warning is ok here - it informs  you that HUGEVAL has been converted to 
the ieee representation of +Infinity, since 1.8e308 exceeds the range of 64bit
ieee floating point arithmetic. 
To avoid it, you can replace HUGEVAL by DBL_MAX (in float.h) if 
you are sure that the largest representable number will suit you. 

As a non portable solution you can store the bit pattern for +Infinity
directly in the memory associated with the double variable - see fp.h
for ideas how to do this. If you take care of the byter order
(DEC/INTEL little vs IBM/HP/SUN big endian) your code should 
be 'pretty portable'.

I am living with the warnings...

-- 
Stefan Schwarzer                office:  +49-(0)711-685-7606   fax: x-3658 
Uni Stuttgart, ICA 1            e-mail:          sts@ica1.uni-stuttgart.de
70569 Stuttgart, Germany             http://www.ica1.uni-stuttgart.de/~sts



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-08-23  4:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <35D24A66.97565B9A@netscape.com>
1998-08-23  4:00 ` HUGEVAL: benign compiler warning under -ieee? Stefan Schwarzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox