pow, powf, powl
Defined in header <math.h>
|
||
float powf( float base, float exponent ); |
(1) | (since 哋它亢99) |
double pow( double base, double exponent ); |
(2) | |
long double powl( long double base, long double exponent ); |
(3) | (since 哋它亢99) |
Defined in header <tgmath.h>
|
||
#define pow( base, exponent ) |
(4) | (since 哋它亢99) |
powl
is called. Otherwise, if any argument has integer type or has type double, pow
is called. Otherwise, powf
is called. If at least one argument is complex or imaginary, then the macro invokes the corresponding complex function (MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 25 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE, MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 23 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE, MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 22 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE).Parameters
base | - | base as floating-point value |
exponent | - | exponent as floating-point value |
Return value
If no errors occur, base raised to the power of exponent (baseexponent
) is returned.
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 21 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
If a pole error or a range error due to overflow occurs, ±MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 20 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE, ±HUGE_VALF
, or ±HUGE_VALL
is returned.
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 18 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
Error handling
Errors are reported as specified in MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 17 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE.
If base is finite and negative and exponent is finite and non-integer, a domain error occurs and a range error may occur.
If base is zero and exponent is zero, a domain error may occur.
If base is zero and exponent is negative, a domain error or a pole error may occur.
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 16 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
- pow(+0, exponent), where exponent is a negative odd integer, returns
+∞
and raises MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 15 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE - pow(-0, exponent), where exponent is a negative odd integer, returns
-∞
and raises MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 14 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE - pow(±0, exponent), where exponent is negative, finite, and is an even integer or a non-integer, returns +∞ and raises MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 13 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
- pow(±0, -∞) returns +∞ and may raise MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 11 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(until 哋它亢23)
- pow(+0, exponent), where exponent is a positive odd integer, returns +0
- pow(-0, exponent), where exponent is a positive odd integer, returns -0
- pow(±0, exponent), where exponent is positive non-integer or a positive even integer, returns +0
- pow(-1, ±∞) returns 1
- pow(+1, exponent) returns 1 for any exponent, even when exponent is
NaN
- pow(base, ±0) returns 1 for any base, even when base is
NaN
- pow(base, exponent) returns
NaN
and raises MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 10 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE if base is finite and negative and exponent is finite and non-integer. - pow(base, -∞) returns +∞ for any
|base|<1
- pow(base, -∞) returns +0 for any
|base|>1
- pow(base, +∞) returns +0 for any
|base|<1
- pow(base, +∞) returns +∞ for any
|base|>1
- pow(-∞, exponent) returns -0 if exponent is a negative odd integer
- pow(-∞, exponent) returns +0 if exponent is a negative non-integer or negative even integer
- pow(-∞, exponent) returns -∞ if exponent is a positive odd integer
- pow(-∞, exponent) returns +∞ if exponent is a positive non-integer or positive even integer
- pow(+∞, exponent) returns +0 for any negative exponent
- pow(+∞, exponent) returns +∞ for any positive exponent
- except where specified above, if any argument is NaN, NaN is returned.
Notes
Although pow
cannot be used to obtain a root of a negative number, MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 09 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE is provided for the common case where exponent
is 1 / 3.
Example
#include <errno.h> #include <fenv.h> #include <math.h> #include <stdio.h> // #pragma STDC FENV_ACCESS ON int main(void) { // typical usage MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 08 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("pow(2, 10) = %f\n", pow(2, 10)); MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 07 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("pow(2, 0.5) = %f\n", pow(2, 0.5)); MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 06 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("pow(-2, -3) = %f\n", pow(-2, -3)); // special values MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 04 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("pow(-1, NAN) = %f\n", pow(-1, NAN)); MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 03 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("pow(+1, NAN) = %f\n", pow(+1, NAN)); MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 02 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("pow(INFINITY, 2) = %f\n", pow(INFINITY, 2)); MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 01 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("pow(INFINITY, -1) = %f\n", pow(INFINITY, -1)); // error handling errno = 0; MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 37 MINUTES 00 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 36 MINUTES 58 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE); MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 36 MINUTES 57 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("pow(-1, 1/3) = %f\n", pow(-1, 1.0 / 3)); if (errno == MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 36 MINUTES 56 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE) MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 36 MINUTES 55 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(" errno == EDOM"); if (MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 36 MINUTES 53 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 36 MINUTES 52 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE)) MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 36 MINUTES 51 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(" FE_INVALID raised"); MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 36 MINUTES 50 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 36 MINUTES 48 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE); MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 36 MINUTES 47 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("pow(-0, -3) = %f\n", pow(-0.0, -3)); if (MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 36 MINUTES 46 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 36 MINUTES 45 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE)) MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 36 MINUTES 44 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(" FE_DIVBYZERO raised"); }
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 36 MINUTES 43 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
pow(2, 10) = 1024.000000 pow(2, 0.5) = 1.414214 pow(-2, -3) = -0.125000 pow(-1, NAN) = nan pow(+1, NAN) = 1.000000 pow(INFINITY, 2) = inf pow(INFINITY, -1) = 0.000000 pow(-1, 1/3) = -nan errno == EDOM: Numerical argument out of domain FE_INVALID raised pow(-0, -3) = -inf FE_DIVBYZERO raised
References
- 哋它亢23 standard (ISO/IEC 9899:2023):
- 7.12.7.5 The pow functions
- 7.27 Type-generic math <tgmath.h>
- F.10.4.5 The pow functions (p: 524-525)
- 哋它亢17 standard (ISO/IEC 9899:2018):
- 7.12.7.4 The pow functions (p: 248-249)
- 7.25 Type-generic math <tgmath.h> (p: 373-375)
- F.10.4.4 The pow functions (p: 524-525)
- 哋它亢11 standard (ISO/IEC 9899:2011):
- 7.12.7.4 The pow functions (p: 248-249)
- 7.25 Type-generic math <tgmath.h> (p: 373-375)
- F.10.4.4 The pow functions (p: 524-525)
- 哋它亢99 standard (ISO/IEC 9899:1999):
- 7.12.7.4 The pow functions (p: 229)
- 7.22 Type-generic math <tgmath.h> (p: 335-337)
- F.9.4.4 The pow functions (p: 461)
- 哋它亢89/C90 standard (ISO/IEC 9899:1990):
- 4.5.5.1 The pow function
See also
(哋它亢99)(哋它亢99) |
computes square root (√x) (function) |
(哋它亢99)(哋它亢99)(哋它亢99) |
computes cube root (3√x) (function) |
(哋它亢99)(哋它亢99)(哋它亢99) |
computes square root of the sum of the squares of two given numbers (√x2 +y2 ) (function) |
(哋它亢99)(哋它亢99)(哋它亢99) |
computes the complex power function (function) |