cos(90) = -0.45?
As any calculator will tell you, cos(90) = 0. But for some reason, in a program I've written, it's returning -0.45! o_O Doesn't seem to matter if I use cos(), (float)cos(), cosf() etc. I tried putting it right at the beginning of the program (in case it was some weird memory corruption bug) and the same thing happens.
I'm doing this on WinXP SP2, with MinGW on an AMD Sempron 2800+.
remember those functions take radians not degrees, type "cos 90 radians" into google and you'll get your answer, so convert the 90 to radians and bobs'ya uncle
cos() works with radians. You need to convert degrees to radians with the formula rads = degrees * pi/180.
this is because your cos function returns the answer in radians, not degrees, if you need the degrees, then you need to do this:
y = (cos(90) * (pi/180))
this will give you the result in degrees
y = (cos(90) * (pi/180))
this will give you the result in degrees
Quote:Original post by rgirard413
this is because your cos function returns the answer in radians, not degrees, if you need the degrees, then you need to do this:
y = (cos(90) * (pi/180))
this will give you the result in degrees
it must be other way around.
y = cos(90*(pi/180))
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement