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, or HUGE_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.0 with the appropriate sign is returned.
  • If x is +0 or -0, and y is an odd integer less than 0, a pole error occurs and HUGE_VAL, HUGE_VALF, or HUGE_VALL is returned, with the same sign as x.
  • If x is +0 or -0, and y is less than 0 and not an odd integer, a pole error occurs and +HUGE_VAL, +HUGE_VALF, or +HUGE_VALL is 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 is 1.0.
  • If x is +1, the result is 1.0 (even if y is a NaN). not even NaN can ruin this one's day. ๐Ÿ’…
  • If y is 0, the result is 1.0 (even if x is a NaN). 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 NaN is 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 a NaN. (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 โ€” errno is set to EDOM. An invalid floating-point exception (FE_INVALID) is raised.
  • Pole error: x is zero, and y is negative โ€” errno is set to ERANGE (but see BUGS). A divide-by-zero floating-point exception (FE_DIVBYZERO) is raised.
  • Range error: the result overflows โ€” errno is set to ERANGE. An overflow floating-point exception (FE_OVERFLOW) is raised.
  • Range error: the result underflows โ€” errno is set to ERANGE. 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 only pow(), and not powf() nor powl(). 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, errno is set to EDOM instead of the POSIX-mandated ERANGE. 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 ๐Ÿงš

cbrt(3), cpow(3), sqrt(3)


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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms