Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Stefan Schwarzer <sts@anaconda.ica1.uni-stuttgart.de>
Subject: Re: HUGEVAL: benign compiler warning under -ieee?
Date: 1998/08/23	[thread overview]
Message-ID: <6rp058$qh2$1@infosun2.rus.uni-stuttgart.de> (raw)
In-Reply-To: 35D24A66.97565B9A@netscape.com

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



           reply	other threads:[~1998-08-23  4:00 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <35D24A66.97565B9A@netscape.com>]
read-only archive

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