Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!hsdndev!cmcl2!lanl!cochiti.lanl.gov!jlg From: jlg@cochiti.lanl.gov (Jim Giles) Newsgroups: comp.lang.c Subject: Re: NaN's (was Re: FLOATING NULL?) Message-ID: <24890@lanl.gov> Date: 1 Jun 91 23:53:34 GMT References: <13223@uhccux.uhcc.Hawaii.Edu> <1991May28.153655.24199@zoo.toronto.edu> <2726@root44.co.uk> <14@tdatirv.UUCP> <1991Jun1.214347.11696@zoo.toronto.edu> Sender: news@lanl.gov Organization: Los Alamos National Laboratory Lines: 18 In article <1991Jun1.214347.11696@zoo.toronto.edu>, henry@zoo.toronto.edu (Henry Spencer) writes: |> [...] It is simply a fact that in IEEE floating point, x!=x |> is sometimes true, and optimizing it to `false' is a compiler bug. I depends on how the `!=' operator is defined in C. The only relational predicate that evaluates `true' under IEEE FP is `unordered'. So, if `!=' is defined as `?<>' (in the IEEE notation: `?' stands for `unordered?'), then it will evaluate `x!=x' as `true' if x is a NAN. However, if `!=' is defined as `<>', then it will _always_ evaluate `x!=x' as `false'. I can't find any specific reference in the ANSI C document which defines which behaviour is appropriate. The ANSI/IEEE document Std 754-1985 (IEEE Standard for Binary Floating-Point Numbers) _recommends_ that the _Fortran_ operator .NE. should be defined as `?<>'. Neither the Fortran nor the C ANSI documents (proposals, in the case of Fortran) mention the issue at all. J. Giles