How many NaNs do we now have?

# Waldemar Horwat (15 years ago)

What should compareTotal do when you compare -NaN and NaN?

Waldemar
# Sam Ruby (15 years ago)

On Mon, Aug 25, 2008 at 7:03 PM, Waldemar Horwat <waldemar at google.com> wrote:

What should compareTotal do when you compare -NaN and NaN?

Re: the subject line; NaN's have a payload that corresponds to the size of the mantissa.

As to the definition of CompareTotal, here's what it contained on Mike's web site[1]:

This function compares two numbers using the IEEE 754 total ordering. If the lhs is less than the rhs in the total order then the number will be set to the value -1. If they are equal, then number is set to 0. If the lhs is greater than the rhs then the number will be set to the value 1.

The total order differs from the numerical comparison in that: –NaN < –sNaN < –Infinity < –finites < –0 < +0 < +finites < +Infinity < +sNaN < +NaN. Also, 1.000 < 1.0 (etc.) and NaNs are ordered by payload.

Waldemar

[1] speleotrove.com/decimal/dnnumb.html

# David-Sarah Hopwood (15 years ago)

Sam Ruby wrote:

On Mon, Aug 25, 2008 at 7:03 PM, Waldemar Horwat <waldemar at google.com> wrote:

What should compareTotal do when you compare -NaN and NaN?

Re: the subject line; NaN's have a payload that corresponds to the size of the mantissa.

No they don't; not in ECMAScript. -NaN is computationally indistinguishable from NaN by ECMAScript code. There is no payload and no quiet/signalling distinction.

# Waldemar Horwat (15 years ago)

David-Sarah Hopwood wrote:

Sam Ruby wrote:

On Mon, Aug 25, 2008 at 7:03 PM, Waldemar Horwat <waldemar at google.com> wrote:

What should compareTotal do when you compare -NaN and NaN? Re: the subject line; NaN's have a payload that corresponds to the size of the mantissa.

No they don't; not in ECMAScript. -NaN is computationally indistinguishable from NaN by ECMAScript code. There is no payload and no quiet/signalling distinction.

That's because ECMAScript doesn't (yet) have compareTotal. When it's added (it's mandatory in IEEE P754), then this will become an interesting question. You will be able to tell whether -NaN somehow produces a different Nan from +NaN.

Waldemar