FP Errors or a bug? Trig functionsArchives Forums/Blitz3D Bug Reports/FP Errors or a bug? Trig functions
Print Tan(90) Print Tan(-90) Print Tan(270) Print Tan(-270)
In theory, these should not only be identical, but should fail too. Interestingly, I tried them on a scientific calculator program and got some completely different and irrational results.
Perhaps This is an inbuilt processor trap designed to prevent against infinities, despite IEEE convention such as Blitz does with Div/0 or NaN etc, should result in infinity?
| It's just the approximate nature of floating point.|
Under the hood 90 degrees is converted to 90*(Pi/180) radians. You would like this to be exactly Pi/2, but it isn't.
What you end up with is Tan( 90 + VerySmallError ). You can tell the error is positive because Tan has become negative.
In fact it is about Tan(90.0000025044817).
| Thanks Floyd! |