NaN
Blitz3D Forums/Blitz3D Programming/NaN
| ||
Why this Happen??? In some times the game Return "NaN" for the positions X,Y and Z of the Player, the screen turn to a Black Screen but the game continues running... Why this happen, what to do to solve this problem? |
| ||
Nan - Not a Number. Caused by division by zero or possibly making the number too large to fit in the data type being used. |
| ||
making it too large will result in a wrap. But division by ~ zero, normally caused by strange timing code that does not make sure it does not go on until timeDiff > 0 |
| ||
Thanks, but, The Unique thing I'm doing is: MoveEntity Player,0,0,.2 Nothing more, what's wrong? This not happen all the time, only sometimes, also, I can't finish the game because this... |
| ||
That won't be your issue, suggest looking elsewhere. Probably best to print all relevant vars to the screen and from there you can see which one is instigating the NaN. Have you checked your camera movement - that may be your issue? Can you post the code? Stevie |
| ||
It means you need to ask your nan. |
| ||
Naan Bread. |
| ||
> MoveEntity Player,0,0,.2 Are you sure it is on that line that the error is occuring? If so then there may be a bug in the moveentity command. Seems unlikely, but possible. |
| ||
Looking in the Debug window when the error occurr, the variables X#,Y# and Z# what here represent the positions X,Y,Z of the player, are with the same values.... X# = -2147483648 Y# = -2147483648 Z# = -2147483648 All Negative |
| ||
Those are integer values. You can tell because Blitz always shows floating point values with decimal point. The integer value -2147483648 is what you get when you assign a floating point Infinity or NaN to an integer variable. x# = 0.0 x# = 1/x Print "x = " + x n = x Print "n = " + n WaitKey The most likely culprit here is dividing a floating point variable by zero. The other possibility is that a number has "overflowed", simply becoming to large to be represented. But if you are typically moving by steps of 0.2 then that would take a very long time. |