exp(3)

✨ exp β€” bestie we're doing e^x today ✨

okay so this is exp(3), from the Math library section of the manual (that's man section 3, iykyk). it's the base-e exponential function and it's literally the moment e gets raised to a power. iconic behavior honestly πŸ’…


🌸 NAME 🌸

exp, expf, expl β€” base-e exponential function

like. the function. the e^x one. the main character of calculus 🫢


πŸŽ€ LIBRARY πŸŽ€

Math library (libm, -lm)

so bestie you gotta link it, okay? -lm. put it at the end of your compile line or gcc will simply not know her πŸ’€


✨ SYNOPSIS ✨

#include <math.h>

double exp(double x);
float expf(float x);
long double expl(long double x);

two things: one, #include <math.h> β€” mandatory, no exceptions, she lives there. two, pick your flavor: double gets you exp, float gets you expf, long double gets you expl. choose your fighter 🌈

πŸ¦‹ Feature Test Macro Requirements for glibc (see feature_test_macros(7)): πŸ¦‹

expf(), expl():
    _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
        || /* Since glibc 2.19: */ _DEFAULT_SOURCE
        || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

yep, this is the classic "glibc gatekeeps the declaration unless you define the right macro" situation. exp (the double one) doesn't need this, but her sisters expf() and expl() do. define one of those and you're in. don't, and the compiler will be like "who?" πŸ™ˆ


πŸ’– DESCRIPTION πŸ’–

These functions return the value of e (the base of natural logarithms) raised to the power of x.

that's it. that's the whole vibe. e^x. the growth curve. the compounding interest. the radioactive decay. the way she just... exponentially increases. no cap.


πŸ”₯ RETURN VALUE πŸ”₯

On success, these functions return the exponential value of x. slay πŸ’…

  • If x is a NaN, a NaN is returned. (NaN in, NaN out, the energy is conserved fr fr)
  • If x is positive infinity, positive infinity is returned.
  • If x is negative infinity, +0 is returned.
  • If the result underflows, a range error occurs, and zero is returned.
  • If the result overflows, a range error occurs, and the functions return +HUGE_VAL, +HUGE_VALF, or +HUGE_VALL, respectively.

so like. she either gives you a number, gives you a bigger number, gives you zero, or gives you +HUGE_VAL-coded drama. there is no in between πŸ‘‘


πŸ’€ ERRORS πŸ’€

See math_error(7) for information on how to determine whether an error has occurred when calling these functions. (bestie, that's the "how do i even know if it went wrong" page. go read it.)

The following errors can occur:

  • Range error, overflow β€” errno is set to ERANGE. An overflow floating-point exception (FE_OVERFLOW) is raised.
  • Range error, underflow β€” errno is set to ERANGE. An underflow floating-point exception (FE_UNDERFLOW) is raised.
⚠️ heads up: both of these set errno to ERANGE, one of them because the number got too big and the other because it got too smol. yes they share a code. yes that's annoying. that's just how it is πŸ™ƒ

πŸ‘‘ ATTRIBUTES πŸ‘‘

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

  • Interface: exp(), expf(), expl()
  • Attribute: Thread safety
  • Value: MT-Safe

translation: she's MT-Safe, so go ahead and call her from multiple threads, she can handle it, she's built different 🫢


🌈 STANDARDS 🌈

C11, POSIX.1-2008.

certified. legit. standards-approved. periodt πŸ’…


πŸŽ€ HISTORY πŸŽ€

C99, POSIX.1-2001.

The variant returning double also conforms to SVr4, 4.3BSD, C89.

so the double girlie has been around since forever, retro icon, OG main character energy ⭐


πŸ¦‹ SEE ALSO πŸ¦‹

cbrt(3), cexp(3), exp10(3), exp2(3), expm1(3), sqrt(3)

the whole exponent/root friend group honestly. go say hi 🌸


okay bestie that's the whole page πŸ’– go forth and compute e^x responsibly.

this has been the Linux man-pages, version 6.20, dated 2026-02-08 β€” entry exp(3). mwah. no notes. ✨
πŸ“¦ 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