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.
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
Post a Comment