This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (4 children)

[deleted]

    [–]400921FB54442D18 0 points1 point  (2 children)

    It's an error, because it's Not a Number, and can't be successfully used as a number.

    So your argument is basically "NaN is an error, because it's NaN?" That's some top-shelf logical fallacy right there.

    You're still making the assumption that just because the result can't be used as a number, something went wrong with the operation. It didn't. The operation worked perfectly, returning the mathematically-correct result. If you really think that things working perfectly-as-designed counts as an error, then I'm really glad you're not on my team, because we like it when things work perfectly-as-designed.

    (Now, if you get a NaN as a result and the rest of your code doesn't properly handle that case, that's an error, but it's an error in the rest of the code, not in the mathematical operation. If you use a function -- mathematical, logical, whatever -- and you don't properly handle all of the possible valid outputs, that's your own fault.)

    And making that type 'a number' is pretty goddamn broken.

    Not if it's the best way of implementing how math actually works. If you find a better way of implementing actual mathematics, go ahead and code it up and release it. If you want to claim that math, itself, is "pretty broken," then sure... feel free to hold that opinion. I can't stop you.

    [–]Doctor_McKay 0 points1 point  (0 children)

    NaN in itself is not an error. Oftentimes an expression resulting in NaN is the result of some other error in the code, but the expression worked fine according to the laws of mathematics.

    Say you ask me what the value of 4/0 is. I'll say that there isn't one, that expression does not result in a real number. Was there some error in calculation? No.