Path: utzoo!attcan!uunet!snorkelwacker!tut.cis.ohio-state.edu!rutgers!news-server.csri.toronto.edu!dgp.toronto.edu!rodney From: rodney@dgp.toronto.edu (Rodney Hoinkes) Newsgroups: comp.sys.sgi Subject: MINFLOAT Summary: can anyone explain this... Message-ID: <1990Jul31.121947.25092@jarvis.csri.toronto.edu> Date: 31 Jul 90 16:19:47 GMT Distribution: na Organization: CSRI, University of Toronto Lines: 55 I have been working with a routine in which I need to determine whether a variable is out of the bounds of a float (NaN etc.), so I have been trying to check it against MINFLOAT and MAXFLOAT as defined in values.h. If I check if(val > MAXFLOAT) ... this works fine for NaN problems BUT! if val = 0.0, and I do the following if(val < MINFLOAT) ... it tells me that val IS less than MINFLOAT The test program below shows this simply: #include #include #define ZERO 0.0 main() { printf("MINFLOAT %g ZERO %g\n",MINFLOAT,ZERO); if(ZERO < MINFLOAT) printf("ZERO is less than MINFLOAT\n"); else printf("ZERO is greater than MINFLOAT\n"); } compiled with cc test.c -lc_s -o test I get the following output: MINFLOAT 1.4013e-45 ZERO 0 ZERO is less than MINFLOAT Can anyone explain? If I printf %f they both return 0.00000 or whatever. -- Rodney Hoinkes Centre for Landscape Research University of Toronto CANADA rodney@dgp.toronto.edu