Alonso Del Arte
1 min readAug 8, 2020

--

This comes straight from IEEE: if the exponent bits of the floating point value are all 1s, then the value is NaN, regardless of the sign bit, provided that at least one of the mantissa bits is a 1 (otherwise it's positive or negative infinity).

For example, 0x4248 is a sometimes adequate "half-precision" approximation of π. But 0x7E48 is NaN, as is any number from 0x7C01 to 0x7FFF, as well as any number from 0xFC01 to 0xFFFF.

Also, there's positive and negative zero, but I don't know how to manifest those in JavaScript.

Java's two floating point primitive wrapper classes have Boolean functions to determine if a floating point value is NaN or not. To my knowledge, JavaScript has no such function, though I do believe such a function can be written, given Evan Wallace's Float Toy: http://evanw.github.io/float-toy/

--

--

Alonso Del Arte
Alonso Del Arte

Written by Alonso Del Arte

is a Java and Scala developer from Detroit, Michigan. AWS Cloud Practitioner Foundational certified

No responses yet