Anyone know a way to calculate the nth root in Xcode
I use the following for square root and tube root
i found a way to do it with the powers
display2 is a hidden textfield
anyone know of a way to do roots and also is there a better way to do the powers one
I use the following for square root and tube root
Code:
- (IBAction)SquareRoot:(id)sender
{
float result = sqrt([display floatValue]);
[display setFloatValue:result];
}
Code:
- (IBAction)QubeRoot:(id)sender
{
float result = cbrtf([display floatValue]);
[display setFloatValue:result];
}
i found a way to do it with the powers
Code:
- (IBAction)Power:(id)sender
{
if ([display2 floatValue]==FALSE)
{
float result = [display floatValue];
[display2 setFloatValue:result];
(display.stringValue=@"");
}
else{
float result = powf([display2 floatValue], [display floatValue]);
[display setFloatValue:result];
(display2.stringValue=@"");
}
}
display2 is a hidden textfield
anyone know of a way to do roots and also is there a better way to do the powers one