Working on a specific calculation, got some great help last time! Getting an error now:
Too few arguments to function call, expected 2, have 1
But there are two arguments! The division of twodouble and onedouble will result in one number, the other (1.0/3), being the second argument. Ideas? (Code is below).
-(IBAction)calculate:(id)sender{
NSString *oneField = self.one.text;
NSString *twoField = self.two.text;
double resultInNum;
double one开发者_运维问答double = [oneField doubleValue];
double twodouble = [twoField doubleValue];
resultInNum = pow((twodouble/onedouble),(1.0/3))*.999)*5.005;
NSString *finalValue = [[NSString alloc] initWithFormat:@"%.3f", resultInNum];
self.result.text = finalValue;
}
resultInNum = pow((twodouble/onedouble),(1.0/3))*.999)*5.005;
Should be:
resultInNum = pow(twodouble/onedouble, 1.0/3)*0.999*5.005;
Just to let you know: pow is a C function and doesn't use a messaging system like Obj-C methods. My gut instinct is telling me you might be thinking like that.
You have too many parentheses. Look carefully. You're only passing one argument to the pow function.
resultInNum = ((pow(twodouble/onedouble),(1.0/3));
should be
resultInNum = pow((twodouble/onedouble),(1.0/3));
EDIT: It looks like you updated your code after I posted my answer. You're still messing up the parentheses.
pow((twodouble/onedouble),(1.0/3))*.999)*5.005;
should be:
pow((twodouble/onedouble),(1.0/3))*.999*5.005;
精彩评论