agree that number producing operations produce numbers.
but i am still convinced that literally, NotANumber means something that is not a number, therefore I would not expect it from number producing operations. and actually i still find counterintuitive that something of Type Number, is then... well NotANumber... :-)
Those interfaces could have been designed to signal an error out of band, but weren't.
So they return the error indicator like any other value, and since they return type number, this means that number must include those error indicators.
Of course, those error indicators aren't valid numbers, so you end up things of type number which aren't numbers, and so NaN. :)
Ecmascript defines NaN as: 'Number value that is an IEEE 754-2019 βNot-a-Numberβ value'.
So you can point the blame for this decision at ecma and IEEE, and wish they had decided differently, but this is the way it turned out.
There are some advantages to this design in that they avoid a need to support early exit from numeric pipelines.
And some disadvantages -- the NaNs will happily keep flowing through, contaminating everything they touch, until you actually check to see if you have some.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
agree that number producing operations produce numbers.
but i am still convinced that literally, NotANumber means something that is not a number, therefore I would not expect it from number producing operations. and actually i still find counterintuitive that something of Type Number, is then... well NotANumber... :-)
Those interfaces could have been designed to signal an error out of band, but weren't.
So they return the error indicator like any other value, and since they return type number, this means that number must include those error indicators.
Of course, those error indicators aren't valid numbers, so you end up things of type number which aren't numbers, and so NaN. :)
Ecmascript defines NaN as: 'Number value that is an IEEE 754-2019 βNot-a-Numberβ value'.
So you can point the blame for this decision at ecma and IEEE, and wish they had decided differently, but this is the way it turned out.
There are some advantages to this design in that they avoid a need to support early exit from numeric pipelines.
And some disadvantages -- the NaNs will happily keep flowing through, contaminating everything they touch, until you actually check to see if you have some.