ShotgunNinja / Kerbalism

Hundreds of Kerbals were killed in the making of this mod.
The Unlicense
43 stars 19 forks source link

Fix Lib.FastRandomFloat Overflow Exception #101

Closed PiezPiedPy closed 7 years ago

PiezPiedPy commented 7 years ago

Fix to Lib.FastRandomFloat() function to stop it throwing an overflow exception, (noticed it while debugging). Downside is it computes slower but its safer.

ShotgunNinja commented 7 years ago

The function is meant to overflow. It is designed that way. That is part of the algorithm.

Overflowing is not bad in itself. Rather is just something to be aware of, and even to exploit like in this case.

I suggest you turn off overflow exceptions in your compiler instead. The flag is called 'Check for arithmetic overflow/underflow' in SharpDevelop. Probably VisualStudio has a similar one.