How do you use sin, cos, and tan in the iPhone sdk? And also how do you use the inverse of them?
Thanks
Thanks
But when I do "tan(1)" in xcode it gives me back 1556013989!?!? But the tan of 1 is 0.017455... What am I doing wrong?
Thanks
#include <math.h>
double
tan(double x);
long double
tanl(long double x);
float
tanf(float x);
DESCRIPTION
The tan() function computes the tangent of x (measured in radians).
#import "MainView.h"
@implementation MainView
-(void)awakeFromNib {
Text.text = [NSString stringWithFormat:@"%d", tan(1)];
}
@end
-(void)awakeFromNib {
Text.text = [NSString stringWithFormat"%d", tan(1)];
}
There's your problem, tan returns a double but the %d format string expects an integer. Changing the '%d' to '%lf' should fix that. Typing 'man 3 printf' at the terminal will give you a lot more information about the printf-style format strings that Apple (and a lot of other libraries) use; look for the part that starts with "The format string is composed of zero or more directives"
double a,b;
...
if (a == b) {
...
float a,b,c,prod1,prod2;
... // compute values for a, b, and c
prod1 = a*b*c;
prod2 = c*b*a;
if (prod1 == prod2) {
...