lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Nov 18, 2005 at 06:45:14PM -0500, Rici Lake wrote:
> On 18-Nov-05, at 12:18 PM, Mike Pall wrote:
> >It's clearly a violation of the standard to optimize this
> >comparison away for floating point numbers.
> 
> Which standard would that be? :) All I see in the C standard is that 
> the value of a comparison or equality operator is "1 if the specified 
> relation is true and 0 if it is false".

C99 (or at least the draft) says this in 6.2.6.1 #4:

  [...] Two values (other than NaNs) with the same object
  representation compare equal [...]

This would seem to require a special case for comparisons if either
value could possibly be NaN.

There's also this over in 7.12.14 #1:

  The relational and equality operators support the usual mathematical
  relationships between numeric values. [...] For a NaN and a numeric
  value, or for two NaNs, just the unordered relationship is true.

                                                  -Dave Dodge