floating point - Why do we have "is not a Number" (isNan) functions? -


many languages have isnan() function. asking myself: why check not being number?

is reason purely logical or faster check not number instead of is number?

note pure question of understanding. know can negate isnan() achieve isnumber() function example.
searching reason why checking not number?

in computing, nan (not number) value of numeric data type representing undefined or unrepresentable value, in floating-point calculations.

wiki article

because not number special case of expression.

you can't use 0 or -1 or because numbers have meanings.

not number means went awry in calculation , valid number cannot computed out of it.

it's on same line of thinking having null. sure, assign arbitrary numerical value mean null confusing , we'd hit sorts of weird errors on corner cases.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -