# cos(90) = -0.45?

This topic is 4684 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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+.

##### Share on other sites
cos() works with radians. You need to convert degrees to radians with the formula rads = degrees * pi/180.

##### Share on other sites
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

##### Share on other sites
Ah, yes. Been so long since I did trig, heh. Thanks!

##### Share on other sites
Quote:
 Original post by rgirard413this 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))

##### Share on other sites
Yeah, I figured that part out once I thought back to degrees vs radians. Thanks though.

1. 1
2. 2
Rutin
22
3. 3
4. 4
5. 5

• 16
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632928
• Total Posts
3009264
• ### Who's Online (See full list)

There are no registered users currently online

×