Path: 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 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 >#include > >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