x raised to the power of n. If n is negative the result is 1 / pow(x, -n), which is calculated as integer division with remainder. This may result in a division by zero error.
If both x and n are 0, the result is 1.
If x is 0 and n is negative, the result is the same as the result of a division by zero.
1 assert(pow(2, 3) == 8); 2 assert(pow(3, 2) == 9); 3 4 assert(pow(2, 10) == 1_024); 5 assert(pow(2, 20) == 1_048_576); 6 assert(pow(2, 30) == 1_073_741_824); 7 8 assert(pow(0, 0) == 1); 9 10 assert(pow(1, -5) == 1); 11 assert(pow(1, -6) == 1); 12 assert(pow(-1, -5) == -1); 13 assert(pow(-1, -6) == 1); 14 15 assert(pow(-2, 5) == -32); 16 assert(pow(-2, -5) == 0); 17 assert(pow(cast(double) -2, -5) == -0.03125);
Compute the power of two integral numbers.