Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!tdatirv!sarima From: sarima@tdatirv.UUCP (Stanley Friesen) Newsgroups: comp.lang.c Subject: Re: NaN's (was Re: FLOATING NULL?) Message-ID: <14@tdatirv.UUCP> Date: 31 May 91 19:23:13 GMT References: <13223@uhccux.uhcc.Hawaii.Edu> <1991May28.153655.24199@zoo.toronto.edu> <2726@root44.co.uk> Reply-To: sarima@tdatirv.UUCP (Stanley Friesen) Organization: Teradata Corp., Irvine Lines: 14 In article <2726@root44.co.uk> gwc@root.co.uk (Geoff Clare) writes: >I agree there is no standard way of generating NaN (although sqrt(-1.0) >is your best bet). However, there is a standard way of testing for NaN. >If x is a floating point variable, then (x != x) will be TRUE if and >only if x has the value NaN. But what if the compiler notices you are asking for a self comparison and optimizes it away? Then this will fail unless x is volatile. Since NaN's fall in the area of unspecified/undefined behavior I believe that such an optimization is legal under the ANSI standard. -- --------------- uunet!tdatirv!sarima (Stanley Friesen)