pow(3)
โจ pow(3) โ bestie, it's the Library Functions Manual page for the power functions โจ
okay so welcome to pow(3), the library functions manual entry that's literally just "raise a number to a power" but make it โจdramaticโจ because floating point is a whole personality. ๐
๐ธ NAME ๐ธ
pow, powf, powl โ power functions ๐ฅ
๐ LIBRARY ๐
Math library (libm, -lm) โ don't forget the -lm, bestie, the linker will be so dramatic about it if you do. ๐ญ
๐ฆ 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);
๐ Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
powf(), powl():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
like, yes, you have to define the right macro or glibc acts like it's never met you. ๐ iykyk.
โจ DESCRIPTION โจ
These functions return the value of x raised to the power of y. that's it. that's the whole job. math queen behavior. ๐
๐ฅ RETURN VALUE ๐ฅ
so this is the part where the vibe check gets intense, because there are a LOT of special cases and every single one of them is iconic in its own way. buckle up. ๐ข
- On success, these functions return the value of x to the power of y. slay.
- If the result overflows, a range error occurs, and the functions return
HUGE_VAL,HUGE_VALF, orHUGE_VALL, respectively, with the mathematically correct sign. big number but make it sign-accurate. - If the result underflows, and is not representable, a range error occurs, and
0.0with the appropriate sign is returned. - If x is
+0or-0, and y is an odd integer less than 0, a pole error occurs andHUGE_VAL,HUGE_VALF, orHUGE_VALLis returned, with the same sign as x. - If x is
+0or-0, and y is less than 0 and not an odd integer, a pole error occurs and+HUGE_VAL,+HUGE_VALF, or+HUGE_VALLis returned. - If x is
+0(-0), and y is an odd integer greater than 0, the result is+0(-0). - If x is
0, and y greater than 0 and not an odd integer, the result is+0. - If x is
-1, and y is positive infinity or negative infinity, the result is1.0. - If x is
+1, the result is1.0(even if y is aNaN). not even NaN can ruin this one's day. ๐ - If y is
0, the result is1.0(even if x is aNaN). the zero exponent ate and left no crumbs. - If x is a finite value less than 0, and y is a finite noninteger, a domain error occurs, and a
NaNis returned. ๐ - If the absolute value of x is less than 1, and y is negative infinity, the result is positive infinity.
- If the absolute value of x is greater than 1, and y is negative infinity, the result is
+0. - If the absolute value of x is less than 1, and y is positive infinity, the result is
+0. - If the absolute value of x is greater than 1, and y is positive infinity, the result is positive infinity.
- If x is negative infinity, and y is an odd integer less than 0, the result is
-0. - If x is negative infinity, and y less than 0 and not an odd integer, the result is
+0. - If x is negative infinity, and y is an odd integer greater than 0, the result is negative infinity.
- If x is negative infinity, and y greater than 0 and not an odd integer, the result is positive infinity.
- If x is positive infinity, and y less than 0, the result is
+0. - If x is positive infinity, and y greater than 0, the result is positive infinity.
- Except as specified above, if x or y is a
NaN, the result is aNaN. (everything else has been handled, so NaN just gets to be NaN. main character energy.)
๐ญ ERRORS ๐ญ
See math_error(7) for info on how to figure out whether an error has occurred when you call these functions. yes, you have to check. no, it won't tell you unprompted. bestie energy honestly.
The following errors can occur:
- Domain error: x is negative, and y is a finite noninteger โ
errnois set toEDOM. An invalid floating-point exception (FE_INVALID) is raised. - Pole error: x is zero, and y is negative โ
errnois set toERANGE(but seeBUGS). A divide-by-zero floating-point exception (FE_DIVBYZERO) is raised. - Range error: the result overflows โ
errnois set toERANGE. An overflow floating-point exception (FE_OVERFLOW) is raised. - Range error: the result underflows โ
errnois set toERANGE. An underflow floating-point exception (FE_UNDERFLOW) is raised.
๐ ATTRIBUTES ๐
For an explanation of the terms used in this section, see attributes(7).
pow(),powf(),powl()โ Thread safety โMT-Safe
like, they're thread safe. go off, queen. ๐ซถ
โญ STANDARDS โญ
C11, POSIX.1-2008.
๐ HISTORY ๐
C99, POSIX.1-2001.
The variant returning double also conforms to SVr4, 4.3BSD, C89. the og. the blueprint. ๐
๐ BUGS ๐
๐ Historical bugs (now fixed) ๐
- Before glibc 2.28, on some architectures (e.g., x86-64)
pow()may be more than 10,000 times slower for some inputs than for other nearby inputs. ๐ฑ This affects onlypow(), and notpowf()norpowl(). This problem was fixed in glibc 2.28. - A number of bugs in the glibc implementation of
pow()were fixed in glibc 2.16. - In glibc 2.9 and earlier, when a pole error occurs,
errnois set toEDOMinstead of the POSIX-mandatedERANGE. Since glibc 2.10, glibc does the right thing. โจgrowthโจ - In glibc 2.3.2 and earlier, when an overflow or underflow error occurs, glibc's
pow()generates a bogus invalid floating-point exception (FE_INVALID) in addition to the overflow or underflow exception. that's giving "extra for no reason" and not in a cute way. ๐ญ
๐ง SEE ALSO ๐ง
lowkey the whole takeaway: pow() is simple on the surface and a menace underneath, but now you know every single edge case and that's what we call a glow up. ๐
okay that's the page!! ๐
โจ this was Linux man-pages 6.20, dated 2026-02-08, and honestly? she served. go call pow() on purpose, not by accident. ๐๐ฆ๐ธ๐
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms