4 ms·
I prefer the IEEE 754 solution: NaN.
by TazeTSchnitzel 11y ago
I prefer the IEEE 754 solution: NaN.
- Zekio 11y agoThat definition is technically true since it is equal to a black hole inside a black hole.
- TheLoneWolfling 11y agoI find that the bane of my existence. It is far better in almost all cases to have it be something vaguely sensible than to have it pop out a virus that infects everything down the line.
- TazeTSchnitzel 11y ago> I find that the bane of my existence. Then don't use it. You can trap it, you know. > It is far better in almost all cases to have it be something vaguely sensible than to have it pop out a virus that infects everything down the line. It isn't better, because now your program produces incorrect results and you don't know about it.
- TheLoneWolfling 11y agoFor game programming, it is decidedly better to produce subtly incorrect results, at least on a release build, than NaN everywhere.
- yoklov 11y agoIn game programming you want it to be 0 as often as you want it to be 1 (or really, less often). Just write a safeDiv function that takes an argument for what the result should be if the denominator is zero.
- jordigh 11y agoNo. 0/0 cannot be logically given a real value. Make your NaNs signalling if it's a problem. Raise an exception like Python does by default, or warn like modern numpy does. But don't make 0/0 complete and absolute contradictory nonsense like a real value.