POW(3POSIX)
๐ POW(3POSIX) โ the POSIX Programmer's Manual ๐
okay bestie, so this one is pow(3POSIX) from the POSIX Programmer's Manual โ yes that's the real manual name, we're not making it up. buckle up, it's giving math girlie energy and there's a LOT of edge cases. ๐งฎโจ
๐จ PROLOG ๐จ
okay so first things first, real talk: this page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ โ so if you're on Linux, go peek at the corresponding Linux manual page for the deets on Linux behavior. OR. plot twist. the interface may not even be implemented on Linux at all. ๐ so vibe check your platform first, bestie.
โจ NAME โจ
pow, powf, powl โ the power function, aka "x to the y, let's go" ๐
๐ธ SYNOPSIS ๐ธ
#include <math.h>
double pow(double x, double y);
float powf(float x, float y);
long double powl(long double x, long double y);
three flavors, one destiny: double, float, long double ๐
๐ฆ DESCRIPTION ๐ฆ
okay so the functionality on this reference page is aligned with the ISO C standard. and if there's any conflict between what's written here and the ISO C standard? that's unintentional, not a bit. this volume of POSIX.1โ2017 defers to the ISO C standard, periodt.
so what do these do? they shall compute the value of x raised to the power y, aka x<sup>y</sup>. simple! iconic! ๐ฅ
BUT. if x is negative, the application shall ensure that y is an integer value. no cap. that's on you.
and if you're the kind of girlie who wants to check for error situations? here's the ritual ๐ฏ๏ธ: set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. then on return, if errno is non-zero, or if
fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)
is non-zero, then bestie... an error has occurred. ๐ญ
๐ RETURN VALUE ๐
okay this is the long one, grab a snack ๐
upon successful completion, these functions shall return the value of x raised to the power y.
- for finite values of x < 0, and finite non-integer values of y, a domain error shall occur and either a
NaN(if representable), or an implementation-defined value shall be returned. - if the correct value would cause overflow, a range error shall occur and
pow(),powf(), andpowl()shall returnยฑHUGE_VAL,ยฑHUGE_VALF, andยฑHUGE_VALL, respectively, with the same sign as the correct value of the function. - if the correct value would cause underflow, and is not representable, a range error may occur, and
pow(),powf(), andpowl()shall return0.0, or (if IEC 60559 Floating-Point is not supported) an implementation-defined value no greater in magnitude thanDBL_MIN,FLT_MIN, andLDBL_MIN, respectively. - for y < 0, if x is zero, a pole error may occur and
pow(),powf(), andpowl()shall returnยฑHUGE_VAL,ยฑHUGE_VALF, andยฑHUGE_VALL, respectively. on systems that support the IEC 60559 Floating-Point option, if x isยฑ0, a pole error shall occur andpow(),powf(), andpowl()shall returnยฑHUGE_VAL,ยฑHUGE_VALF, andยฑHUGE_VALL, respectively if y is an odd integer, orHUGE_VAL,HUGE_VALF, andHUGE_VALL, respectively if y is not an odd integer. - if x or y is a
NaN, aNaNshall be returned (unless specified elsewhere in this description). ๐ - for any value of y (including
NaN), if x is+1,1.0shall be returned. - for any value of x (including
NaN), if y isยฑ0,1.0shall be returned. - for any odd integer value of y > 0, if x is
ยฑ0,ยฑ0shall be returned. - for y > 0 and not an odd integer, if x is
ยฑ0,+0shall be returned. - if x is
-1, and y isยฑInf,1.0shall be returned. - for
|x| < 1, if y is-Inf,+Infshall be returned. - for
|x| > 1, if y is-Inf,+0shall be returned. - for
|x| < 1, if y is+Inf,+0shall be returned. - for
|x| > 1, if y is+Inf,+Infshall be returned. - for y an odd integer < 0, if x is
-Inf,-0shall be returned. - for y < 0 and not an odd integer, if x is
-Inf,+0shall be returned. - for y an odd integer > 0, if x is
-Inf,-Infshall be returned. - for y > 0 and not an odd integer, if x is
-Inf,+Infshall be returned. - for y < 0, if x is
+Inf,+0shall be returned. - for y > 0, if x is
+Inf,+Infshall be returned. - if the correct value would cause underflow, and is representable, a range error may occur and the correct value shall be returned.
like. that's a whole mood board of infinities and zeros. obsessed. ๐
๐ฅ ERRORS ๐ฅ
these functions shall fail if:
- Domain Error โ the value of x is negative and y is a finite non-integer.
- if the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[EDOM]. - if the integer expression
(math_errhandling & MATH_ERREXCEPT)is non-zero, then the invalid floating-point exception shall be raised.
- if the integer expression
- Pole Error โ the value of x is zero and y is negative.
- if the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[ERANGE]. - if the integer expression
(math_errhandling & MATH_ERREXCEPT)is non-zero, then the divide-by-zero floating-point exception shall be raised.
- if the integer expression
- Range Error โ the result overflows.
- if the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[ERANGE]. - if the integer expression
(math_errhandling & MATH_ERREXCEPT)is non-zero, then the overflow floating-point exception shall be raised.
- if the integer expression
these functions may fail if:
- Pole Error โ the value of x is zero and y is negative.
- if the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[ERANGE]. - if the integer expression
(math_errhandling & MATH_ERREXCEPT)is non-zero, then the divide-by-zero floating-point exception shall be raised.
- if the integer expression
- Range Error โ the result underflows.
- if the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[ERANGE]. - if the integer expression
(math_errhandling & MATH_ERREXCEPT)is non-zero, then the underflow floating-point exception shall be raised.
- if the integer expression
yes the pole error shows up in both lists. that's not a typo, that's canon, and I'm not editing the source material bestie ๐ซถ
oh and heads up: the following sections are informative. so like, no pressure, but here they come anyway.
๐ EXAMPLES ๐
None. ๐ญ not a single example. the girls gave us nothing. it's giving mysterious.
๐ APPLICATION USAGE ๐
on error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other โ but at least one of them must be non-zero. them's the rules. โญ
๐ RATIONALE ๐
None. iconic of them honestly.
๐ง FUTURE DIRECTIONS ๐ง
None. the future is a mystery, we stan a blank slate โจ
๐ SEE ALSO ๐
exp()feclearexcept()fetestexcept()isnan()
and from the Base Definitions volume of POSIX.1โ2017:
- Section 4.20, Treatment of Error Conditions for Mathematical Functions
<math.h>
๐ COPYRIGHT ๐
so, legal girlie moment, don't skip this part:
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page bestie!! ๐ซถ this one came to you courtesy of IEEE/The Open Group, 2017 โ so when you see POW(3POSIX) in your man pages, you know exactly whose name is on it ๐
โจ slay, go raise some numbers to some powers responsibly ๐ธ๐
๐ฆ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 ยท Other
- debian trixie: manpages-posix-dev 2017a-2 ยท Other
- ubuntu jammy: manpages-posix-dev 2017a-2 ยท Other
- ubuntu noble: manpages-posix-dev 2017a-2 ยท Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 ยท Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 ยท Other
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms