Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!twinsun.com!eggert From: eggert@twinsun.com (Paul Eggert) Newsgroups: gnu.gcc Subject: Re: IEEE FLP question: Use of NAN and Inf Message-ID: <8912200113.AA07280@rise.twinsun.com> Date: 20 Dec 89 01:13:52 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 22 phd_ivo@gsbacd.uchicago.edu writes: Moreover, can someone please tell me how to define the IEEE double's of +Inf, -Inf, and NaN, so that I can assign and test for them? Here's how. #define Inf (1e300 * 1e300) #define NaN (Inf - Inf) `-Inf' gets you minus infinity. There are lots of NaNs; the above method gives you only one of them. Use isnan(X) to test whether X is a NaN. If your vendor doesn't supply isnan() (sigh), this should work: int isnan(x) double x; {return x!=x;} Warning: GCC 1.36 is buggy in this area; 1.37 will have some fixes. Eventually GCC should have full IEEE support rather than relying on vendors.