# Cosine 90 doesn't return zero?

Title explains my problem.
I’m trying to do some dot calculations for my game, and from my understanding, to do degree comparisons, I need to use `math.cos`.
I input said degrees to the function in radians:
`math.cos(math.rad(90))`
but for some very particular reason, this doesn’t return 0, but a stupid number like `6.1232`.

I’ve checked with other values as well,
`math.cos(math.rad(60))` returns `0.5` as expected.
`math.cos(0)` works too, returns `1`.

Is this a bug? Why does only cos90 return a wrong error, but other values don’t?

2 Likes

The cosine of 90 should return 0 if 90 is converted into degrees.

Possibly a bug with converting degrees to radians?
Can you try using the function to convert degrees to radians, and see if you get the same result?

https://love2d.org/forums/viewtopic.php?t=88409
basically its another floating point error by a very small margin

2 Likes

It’s just floating point precision error. The value you get (6.12 * 10^ -17) is very close to zero that it might as well be considered 0. This can be approximated to 0.0000000000000000612

cos90 gives `-.4480`, and cosrad90 gives the funny number.