🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #760

Re: Small numbers

#760
From: Igor Metz
Date: Thu, 26 Oct 1989 10:31
51 lines
2476 bytes
In article <8910250958.13737@munnari.oz.au> mpope@augean.oz.au (Michael T Pope) writes:
>(Sun4/Sparc, SunOS 3.?)
>I am having trouble with small floating point numbers, as shown by the
>following program.
>---------------foo.c------------------
>#include <stdio.h>
>#include <values.h>
>
>static float smallest_positive_float = MINFLOAT;
>static float smallest_negative_float = -MINFLOAT;
>static double smallest_positive_double = MINDOUBLE;
>static double smallest_negative_double = -MINDOUBLE;
>
>int main() {
>  fprintf(stderr, "%e %e\n", smallest_positive_float, MINFLOAT);
>  fprintf(stderr, "%e %e\n", smallest_negative_float, -MINFLOAT);
>  fprintf(stderr, "%e %e\n", smallest_positive_double, MINDOUBLE);
>  fprintf(stderr, "%e %e\n", smallest_negative_double, -MINDOUBLE);
>}

On SparcStation 1/ SunOS 4.0.3/ gcc 1.36 (using as not gas!) I get the
following:

bolek:/tmp% gcc gaga.c
gaga.c:6: warning: floating point number exceeds range of `double'
gaga.c:7: warning: floating point number exceeds range of `double'
gaga.c: In function main:
gaga.c:12: warning: floating point number exceeds range of `double'
gaga.c:13: warning: floating point number exceeds range of `double'
bolek:/tmp% a.out
1.401298e-45 1.401298e-45
-1.401298e-45 -1.401298e-45
4.940656e-324 4.940656e-324
-4.940656e-324 -46e-324

Comparing /usr/include/values.h and /usr/local/lib/gcc-include/float.h:
/usr/include/values.h (from Sun) contains
 #define MINDOUBLE       4.94065645841246544e-324
 #define MINFLOAT        ((float)1.40129846432481707e-45)

while /usr/local/lib/gcc-include/float.h (Produced by hard-params version 4.1,
CWI, Amsterdam) contains
 #define FLT_MIN ((float)1.17549435e-38)
 #define DBL_MIN 2.2250738585072014e-308

Which is correct?
-- 

Igor Metz                    X400: metz@iam.unibe.ch
Institut fuer Informatik     ARPA: metz%iam.unibe.ch@relay.cs.net
und angewandte Mathematik    UUCP: ..!uunet!mcvax!iam.unibe.ch!metz
Technical Details
Message-ID: <1989Oct26.103150.3219@iam.unibe.ch>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!lll-winken!bu-cs!bloom-beacon!eru!luth!sunic!mcsun!cernvax!ethz!chx400!iam!metz
References: <8910250958.13737@munnari.oz.au>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!lll-winken!bu-cs!bloom-beacon!eru!luth!sunic!mcsun!cernvax!ethz!chx400!iam!metz
From: metz@iam.unibe.ch (Igor Metz)
Newsgroups: gnu.gcc.bug
Subject: Re: Small numbers
Message-ID: <1989Oct26.103150.3219@iam.unibe.ch>
Date: 26 Oct 89 10:31:50 GMT
References: <8910250958.13737@munnari.oz.au>
Reply-To: metz@iam.unibe.ch (Igor Metz)
Organization: University of Berne, Dept. of Computer Science
Lines: 51