exp2(3)

✨ exp2 β€” base-2 exponential function, but make it cute ✨

okay bestie, so this is the manual page for the math library girls β€” exp2, exp2f and exp2l πŸŽ€ (that's the libm crew, link it with -lm πŸ’…). It's giving "2 to the power of x" and honestly? iconic.


🌸 NAME 🌸

exp2, exp2f, exp2l β€” the base-2 exponential function. that's the whole vibe πŸ¦‹


πŸ’– LIBRARY πŸ’–

Math library (libm, -lm) β€” yes you gotta add the -lm, no cap, the compiler will literally ghost you otherwise 😭


✨ SYNOPSIS ✨

#include <math.h>

double exp2(double x);
float exp2f(float x);
long double exp2l(long double x);

🧚 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

  • exp2(), exp2f(), exp2l():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L

bestie you need one of these defined or the functions just won't show up. gatekeeping fr πŸ™ˆ


🌈 DESCRIPTION 🌈

These functions return the value of 2 raised to the power of x. that's it. that's the function. 2^x, slay πŸ’–


⭐ RETURN VALUE ⭐

On success, these functions return the base-2 exponential value of x. so like, the answer. the moment. πŸ‘‘

For various special cases β€” including the handling of infinity and NaN, as well as overflows and underflows β€” see exp(3). the special-case lore lives over there, go read it bestie, i'm not retyping all that 🫢


πŸ’€ ERRORS πŸ’€

See math_error(7) for information on how to determine whether an error has occurred when calling these functions. (tl;dr there's a whole system for checking and math_error(7) is the girl who explains it πŸŽ€)

For a discussion of the errors that can occur for these functions, see exp(3). same deal β€” all the error discourse is in exp(3)'s house, not here πŸ’…


πŸ‘‘ ATTRIBUTES πŸ‘‘

For an explanation of the terms used in this section, see attributes(7).

  • exp2(), exp2f(), exp2l() β€” Thread safety: MT-Safe πŸ”₯

so yeah, thread-safe, you can call these from wherever, it's fine, no drama, periodt ✨


πŸŽ€ STANDARDS πŸŽ€

C11, POSIX.1-2008. certified, stamped, official 🫢


🌸 HISTORY 🌸

glibc 2.1. also C99, POSIX.1-2001. the glow-up timeline fr πŸ“œβœ¨

The variant returning double also conforms to SVr4, 4.3BSD. (that's exp2 specifically β€” it's been around, it has range πŸ’œ)


πŸ¦‹ SEE ALSO πŸ¦‹


reminder bestie: exp2 is base 2, not base e. if you wanted e^x you want exp(3), don't mix them up or the math will be wrong and the vibes will be worse πŸ˜­πŸ’–

okay that's the whole page πŸŽ€ this was Linux man-pages 6.20, dated 2026-02-08, and it's exp2(3) if you're searching for it later. mwah, go compute something beautiful βœ¨πŸ’…πŸŒˆ

πŸ“¦ 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