To calculate x^n, considering two cases
-
intPower(x, n)
- x and n, both are of
int
data type
- x and n, both are of
-
floatPower(x, n)
- x and n, both are of
float
data type -
- x and n, both are of
- The intPower and floatPower functions only work when x^n doesn't cross the range of double type
- The intPower and floatPower functions return INT_MAX (indicating error), when ans=0^(-ve number) or ans=(-ve number)^(non-integer number). Hence both the functions fail only at the case x=INT_MAX and n=1
- The floatPower function takes all floating point numbers of x, n except the range ( (-inf < x < 0) and (n is not an integer) )