When is an operation on a NaN variable valid? I would say never.
Yet in AS3 no exception is thrown and the default of 0 is returned when a operation is attempted on such a variable.
Why doesn’t AS3 throw an exception here?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No exception is thrown in AS3 when dealing with
NaNbecause AS3 is a dialect of ECMAScript, which in turn implements IEEE 754, which defines the bahavior ofNaN. This standard is implemented in a bunch of languages and architectures, including ones that do not have robust exception handling.NaNrepresents a way to express these values without requiring exceptions, in a way that is well understood and well documented across a bunch of platforms and languages.If it wasn’t implemented against the standard, then I would be willing to wager there would be people here asking “Why does AS3 throw and exception rather than returning
NaNlike every other IEEE 754 floating point implementation does?!”See “What Every Computer Scientist Should Know About Floating-Point Arithmetic…” for a quick overview on floating point math and
NaNin general, and check out the wikipedia on NaN, and you’ll see there are actually two types of NaN defined by the standard. A quiet NaN and a signaling NaN.No offense intended, I don’t think that you are in the best position to make that absolute statement, because honestly, a lot of people a lot smarter than you in their profession thought about it and didn’t come to the same conclusion.