cos(90)
returns 6.12323e-017
instead of 0
.Code Snippet (if applicable) to Reproduce Problem:
mob/Login()
src << cos(90)
Expected Results:
0
Actual Results:
6.12323e-017
ID:2524704
Nov 23 2019, 11:17 am
|
|||||||||||||
Not a bug
| |||||||||||||
Descriptive Problem Summary:
cos(90) returns 6.12323e-017 instead of 0 .Code Snippet (if applicable) to Reproduce Problem: mob/Login() Expected Results: 0 Actual Results: 6.12323e-017 |
Not actually a bug; this is a limitation of the underlying functions coupled with rounding errors from degrees-to-radians conversion. You can improve the results by doing some reflections around 180, 90, and 45. The code could try to do this internally but at the cost of reduced performance.
Alternatively you could try to round() to the nearest 2**-40 or so which is an exact number in floating point, and that would deal with some inaccuracies when the value of the function is near 0. |
sin()
as well.