The compiler will cast the
ints into
doubles for you. But it wouldn't be a bad practice to explicitly cast them yourself.
resultInt = (int)pow((double)someInt, (double)someOtherInt);
Be aware however, that if the result of the
pow function is greater than the maximum value an
int can hold, the value of the
int won't be what you expected.
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog(@"(double)pow(2, 32) = %lf", (double)pow(2, 32));
NSLog(@"(short int)pow(2, 32) = %hi", (short int)pow(2, 32));
NSLog(@"(unsigned short int)pow(2, 32) = %hu", (unsigned short int)pow(2, 32));
NSLog(@"(int)pow(2, 32) = %i" , (int)pow(2, 32));
NSLog(@"(unsigned int)pow(2, 32) = %u" , (unsigned int)pow(2, 32));
NSLog(@"(long long int)pow(2, 32) = %qi", (long long int)pow(2, 32));
NSLog(@"(unsigned long long int)pow(2, 32) = %qu", (unsigned long long int)pow(2, 32));
[pool drain];
return 0;
}