powr
Compute the value of x raised to the power of y, where x ≥ 0.
Interface Definition
C interface:
float powrf(float x, float y);
double powr(double x, double y);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
y |
|
Floating-point value of the input data. |
Input |
Return Value
- If x is greater than or equal to 0 and y is not a special value, the result of x raised to the power of y is returned. Value range: (0, +INF)
- If x is less than 0, the return value is NaN.
- Other combinations of special values are listed in the following table.
Input Value (x)
Input Value (y)
Output Value (result)
+0
+0
+1
+0
-0
+1
+0
inf
+0
+0
-inf
inf
+0
SNaN
NaN
+0
–SNaN
NaN
+0
QNaN
NaN
+0
–QNaN
NaN
-0
+0
+1
-0
-0
+1
-0
inf
+0
-0
-inf
inf
-0
SNaN
NaN
-0
–SNaN
NaN
-0
QNaN
NaN
-0
–QNaN
NaN
inf
+0
+1
inf
-0
+1
inf
inf
inf
inf
-inf
+0
inf
SNaN
NaN
inf
–SNaN
NaN
inf
QNaN
NaN
inf
–QNaN
NaN
-inf
+0
NaN
-inf
-0
NaN
-inf
inf
NaN
-inf
-inf
NaN
-inf
SNaN
NaN
-inf
–SNaN
NaN
-inf
QNaN
NaN
-inf
–QNaN
NaN
SNaN
+0
+1
SNaN
-0
+1
SNaN
inf
NaN
SNaN
-inf
NaN
SNaN
SNaN
NaN
SNaN
–SNaN
NaN
SNaN
QNaN
NaN
SNaN
–QNaN
NaN
–SNaN
+0
+1
–SNaN
-0
+1
–SNaN
inf
NaN
–SNaN
-inf
NaN
–SNaN
SNaN
NaN
–SNaN
–SNaN
NaN
–SNaN
QNaN
NaN
–SNaN
–QNaN
NaN
QNaN
+0
+1
QNaN
-0
+1
QNaN
inf
NaN
QNaN
-inf
NaN
QNaN
SNaN
NaN
QNaN
–SNaN
NaN
QNaN
QNaN
NaN
QNaN
–QNaN
NaN
–QNaN
+0
+1
–QNaN
-0
+1
–QNaN
inf
NaN
–QNaN
-inf
NaN
–QNaN
SNaN
NaN
–QNaN
–SNaN
NaN
–QNaN
QNaN
NaN
–QNaN
–QNaN
NaN
Dependency
C: "km.h"
Example
C interface:
// typical usage
double x1 = 0.0, x2 = -0.0, x3 = 1.5, x4 = -2.5;
// special handing
double a = INFINITY, b = -INFINITY, c = NAN;
// print result
printf("powr(0.0, -0.0) = %.15f\n", powr(x1, x2));
printf("powr(-0.0, 0.0) = %.15f\n", powr(x2, x1));
printf("powr(1.5, 1.5) = %.15f\n", powr(x3, x3));
printf("powr(-2.5, 1.5) = %.15f\n", powr(x4, x3));
printf("powr(INFINITY, 1.5) = %.15f\n", powr(a, x3));
printf("powr(-INFINITY, 1.5) = %.15f\n", powr(b, x3));
printf("powr(NAN, NAN) = %.15f\n", powr(c, c));
return 0;
/*
* powr(0.0, -0.0) = 1.000000000000000
* powr(-0.0, 0.0) = 1.000000000000000
* powr(1.5, 1.5) = 1.837117307087384
* powr(-2.5, 1.5) = nan
* powr(INFINITY, 1.5) = inf
* powr(-INFINITY, 1.5) = nan
* powr(NAN, NAN) = nan
*/