From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,8c8c3d6a8ecd0e78 X-Google-Attributes: gidfee84,public From: Stefan Schwarzer Subject: Re: HUGEVAL: benign compiler warning under -ieee? Date: 1998/08/23 Message-ID: <6rp058$qh2$1@infosun2.rus.uni-stuttgart.de>#1/1 X-Deja-AN: 383871696 References: <35D24A66.97565B9A@netscape.com> Organization: ICA 1, Stuttgart University User-Agent: tin/pre-1.4-971224 (UNIX) (SunOS/5.5.1 (sun4u)) Newsgroups: comp.unix.osf.osf1 Wan-Teh Chang wrote: : Consider this test program: : --- begin foo_hugeval.c --- : #include : 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