#1
im trying to calculate sin cosine and tan but im getting the wrong calculation

what am i doing wrong

Code:

- (IBAction)sin:(id)sender
{
float result = sin([conv_display floatValue]);
[conv_display setFloatValue:result];
}
- (IBAction)cos:(id)sender
{
float result = cos([conv_display floatValue]);
[conv_display setFloatValue:result];
}
- (IBAction)tan:(id)sender
{
float result = tan([conv_display floatValue]);
[conv_display setFloatValue:result];
}

and also does anyone know how to do inverse sin cos and tan

#3
1. Use doubles instead of floats.

2. What is conv_display and what is [conv_display floatValue] returning? Is it an angle?

3. Angles used by computers are in radians. If [conv_display floatValue] is an angle in degrees you need to convert it from degrees to radians to pass them to trigonometric functions.

4. Why do you take the cosine of [conv_display floatValue] and then set [conv_display floatValue] to it's cosine?

Here is some useful code:

Code:

#include <math.h> //M_PI defined in this header
double degreesToRadians(double x)
{
return((x / 360.0 ) * (2.0 * M_PI));
}/*double degreesToRadians(double x)*/
double radiansToDegrees(double x)
{
return((x / (2.0 * M_PI)) * 360.0);
}/*double degreesToRadians(double x)*/