Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!augean.oz.au!mpope From: mpope@augean.oz.au (Michael T Pope) Newsgroups: gnu.gcc.bug Subject: Small numbers Message-ID: <8910250958.13737@munnari.oz.au> Date: 26 Oct 89 01:27:52 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 63 (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); } 43 Crackle> cc -o foo foo.c 44 Crackle> foo 1.401298e-45 1.401298e-45 -1.401298e-45 -1.401298e-45 4.940656e-324 4.940656e-324 -4.940656e-324 -4.940656e-324 45 Crackle> gcc -v -o foo foo.c gcc version 1.36 /usr/local/gnu/gcc-cpp -v -undef -D__GNUC__ -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ foo.c /tmp/cca02420.cpp GNU CPP version 1.36 /usr/local/gnu/gcc-cc1 /tmp/cca02420.cpp -quiet -dumpbase foo.c -version -o /tmp/cca02420.s GNU C version 1.36 (sparc) compiled by GNU C version 1.36. default target switches: -mfpu -mepilogue -msun-asm foo.c:6: warning: floating point number exceeds range of `double' foo.c:7: warning: floating point number exceeds range of `double' foo.c: In function main: foo.c:12: warning: floating point number exceeds range of `double' foo.c:13: warning: floating point number exceeds range of `double' /usr/local/gnu/gcc-as -o foo.o /tmp/cca02420.s /tmp/cca02420.s:5:cannot create floating-point number /tmp/cca02420.s:8:cannot create floating-point number /tmp/cca02420.s:11:cannot create floating-point number /tmp/cca02420.s:14:cannot create floating-point number /tmp/cca02420.s:31:cannot create floating-point number /tmp/cca02420.s:34:cannot create floating-point number /usr/local/gnu/gcc-ld -o foo /lib/crt0.o foo.o /usr/local/gnu/gcc-gnulib -lc 46 Crackle> foo -NaN 1.401298e-45 -NaN -1.401298e-45 -NaN -NaN -NaN -NaN I checked the source of values.h--- as expected it was picking up /usr/include/values.h, which contains--- #ifdef sun ... #define MINDOUBLE 4.94065645841246544e-324 #define MINFLOAT ((float)1.40129846432481707e-45) ... The version of gas is "1.34 (I guess)" according to gas -v. Cheers, Mike Pope