Validation for NaNs in asm.js code

How can I effectively check the asm.js code, is the floating point value NaN?

A principle that works in principle is to import a global JavaScript function isNaNas an external function into the asm.js. module Since calling a foreign function is expensive, however, this will not give an optimal code.

Comparing with a NaN value (which is part of the standard library) is not an option, because comparing NaN with another NaN always gives a false value in JavaScript semantics.

Studying bits on the heap is also not an option, because endianess is not specified.

Why is isNaNnot included in the standard library in asm.js?

+3
source share
2

NaN :

var isNaN = a!=a; 

Wikipedia:

, x = x false , x NaN

+3
if (value !== value) {
    // Definitely NaN
}

,

function isNaN(inputValue) {
    return inputValue !== inputValue;
}
+2

All Articles