Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't sin() return the correct value?

How do I use sin(), cos(), and tan() functions in iOS application? When I use this I didn't get the correct value. Example:

double value=sin(90);

I got value: 0.893997 but expected value: 1. How can I fix this?

like image 366
Vineesh TP Avatar asked Dec 29 '11 04:12

Vineesh TP


1 Answers

The problem is that it's taking the sine of 90 radians, not degrees. Try sin(M_PI_2) for 90°.

like image 161
Alexsander Akers Avatar answered Nov 13 '22 15:11

Alexsander Akers