4 ms·
Can arithmetic be applyied to NaN a la i? (e.g. 5 + 2 * NaN = 5 + 2NaN)
by scrupulusalbion 9y ago
Can arithmetic be applyied to NaN a la i? (e.g. 5 + 2 * NaN = 5 + 2NaN)
- mort96 9y agoNaN is sort of viral. Any math operator (afaik) returns NaN if any of the operands is NaN. That means `5 + (2 * NaN)` becomes `5 + NaN`, which just becomes `NaN`. Still, `5 + 2 * NaN == 5 + 2 * NaN` would return false, because it becomes `NaN == NaN`, and NaN is not equal to NaN.
- logicallee 9y agowhat about 0 * instead of 2 * ? On one hand by the viral property it would seem to also be unequal? On the other hand having zero NaN is something every equation already has :D it seems fair to silently remove a 0 * NaN term.
- Retra 9y ago"0 * NaN" makes as much sense as "0 * Blue". It's NaN because you're trying to do something that is fundamentally not multiplication.
- logicallee 9y agothanks - makes sense and is a clear explanation.
- mturmon 9y agoIt's not fair to remove 0 * NaN. NaN will come up when doing Inf - Inf But clearly: 0 * (Inf - Inf) cannot be said to be zero. NaN really is not a number.
- hermitdev 9y agoIIRC, but I don't have the IEEE spec in front of me, any operation, binary or unary, that has an operand of NaN shall have the result of NaN.