Like if I I put

I get that a = .525322 when a should be = 7.07106. This happens with all thease kinds of funtions, whats happening?Code:`double a = cos(45);`

- 02-29-2004MarcosWhy do I get wrong values when I use the sin and cos functions?
Like if I I put

Code:`double a = cos(45);`

- 02-29-2004BoredCrzy
a = .525322 because the function cos takes in radians rather than degrees (which should be .707106, not 7.07106)

- 02-29-2004MrWizard
Those functions take radians not degrees.

- 02-29-2004Marcos
duh! of course haha, Thanks a lot for the help guys :)

- 02-29-2004Marcos
oh and... so... like if I want to put cos(45°) (the degrees that you need 360 for a circle) how would I do it? :confused:

- 02-29-2004joshdick
You could write wrapper functions that do the conversions so that when you call them, you can always do it in degrees.

- 02-29-2004BoredCrzy
As Joshdick mentioned, write a wrapper function that converts the degree measure into radians (degree * PI/180)

e.g.

Code:`double sin_d (double degrees)`

{

return (sin(degrees * 3.1416/180));

}