NaN?

Blitz3D Forums/Blitz3D Programming/NaN?

Hi guys. I've got a system that is using some float variables. Something in the math is cousing it to produce a value that prints to the screen as "NaN". This produces undesirable results in my program. Any idea what this "NaN" is?

Not a Number if I recall correctly.

Sounds like you're doing something that either won't take floats or it's doing something so drastic to them that it just won't take it.

Yep, or a divide by zero.

I'm pretty sure a divide by zero would cause Blitz to error out (always did for me).

I've had it where it would Nan by a divide by 0 and wouldn't actually crash until I gave the computer input. Whereby it would then give me a divide by 0 error. When I got that the screen would blank out and I'd still see 2D drawing operations but all 3D would be gone.

Also I meant to say it is a NaN but it can also happen if you divide by 0 which ... seems to happen to me sometimes and Blitz doesn't immediately crash as I stated above.

# divided by 0 = Infinity
A NaN can be caused by 0/0 though.

Here's a nifty Function to detect these 'values', thanks to Koriolis:

Function isNaNOrInf%(f#) 
   Return (f + 1) = f 
End Function


Returns False for a normal number, True for something eville.

An integer divide by zero causes an error, but with floats it just does it!