Not a Number debugging
Blitz3D Forums/Blitz3D Programming/Not a Number debugging
| ||
I'm having trouble debugging my code. There are float variables that mysteriously get NaN's. Is there a way to make the program to halt whenever some result is NaN? In debug mode, that is. I have no idea where the bug is, so this halting needs to be global (supported by debugger). I assume that in my case NaN is 'division by zero' since I don't use much of the math functions. What are the other cases when the result could be NaN? Log() with a negative number could be such? |
| ||
potentially, as log with a negative number is not defined. Another case is division by a very large number so it underflows instead of overflowing as with division by zero. the best thing you can do is debug stop or put in debuglog statements and check the var to see between which 2 points it breaks and debugstop that area. |
| ||
This may be useful too: http://www.blitzbasic.com/Community/posts.php?topic=43157#482824 There have been several discussions about NAN, Infinity, and the philosophy of it and all. Just use the search tool with "NaN". |
| ||
Thanks jfk, maybe I'll be able to catch the problem with a>Infinity. |