expm1(3)

✨ expm1(3) β€” exponential minus 1 ✨

okay bestie, welcome to expm1(3) πŸ’– this is a page from the Library Functions Manual, and we're about to make the whole "subtract 1 from an exponential" situation make sense. no cap.


🫢 NAME 🫢

expm1, expm1f, expm1l β€” exponential minus 1


πŸ“š LIBRARY πŸ“š

Math library (libm, -lm) β€” yeah you gotta link it, that's just the vibe.


🌸 SYNOPSIS 🌸

#include <math.h>

double expm1(double x);
float expm1f(float x);
long double expm1l(long double x);

🧚 Feature Test Macro Requirements for glibc 🧚

(peep feature_test_macros(7) if you want the lore)

expm1():

_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
    || _XOPEN_SOURCE >= 500
    || /* Since glibc 2.19: */ _DEFAULT_SOURCE
    || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

expm1f(), expm1l():

_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
    || /* Since glibc 2.19: */ _DEFAULT_SOURCE
    || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

πŸ’… DESCRIPTION πŸ’…

So these functions return a value equivalent to

exp(x) - 1

but here's the iconic part, the reason she exists: the result gets computed in a way that stays accurate even when x is near zero. that's the case where plain old exp(x) - 1 would be a whole mess, because you'd be subtracting two numbers that are nearly equal and losing all your precision. it's giving catastrophic cancellation. not on her watch. πŸ”₯


πŸ‘‘ RETURN VALUE πŸ‘‘

On success, these functions return exp(x) - 1. periodt.

  • If x is a NaN, a NaN is returned. (NaN in, NaN out, the circle of life πŸ¦‹)
  • If x is +0 (-0), +0 (-0) is returned.
  • If x is positive infinity, positive infinity is returned. 🌈
  • If x is negative infinity, -1 is returned.
  • If the result overflows, a range error occurs, and the functions return -HUGE_VAL, -HUGE_VALF, or -HUGE_VALL, respectively.

😭 ERRORS 😭

Go read math_error(7) if you wanna know how to figure out whether an error even happened when you called one of these. it's all in there.

The following errors can occur:

  • Range error, overflow β€” errno is set to ERANGE (but see BUGS, bestie, there's always a BUGS section). An overflow floating-point exception (FE_OVERFLOW) is raised.

πŸŽ€ ATTRIBUTES πŸŽ€

for what all these terms even mean, see attributes(7).

  • Interface: expm1(), expm1f(), expm1l()
  • Attribute: Thread safety
  • Value: MT-Safe

thread safe, no drama, we love her for that 🫢


⭐ STANDARDS ⭐

C11, POSIX.1-2008.


πŸ¦‹ HISTORY πŸ¦‹

C99, POSIX.1-2001. BSD.

ancient. legendary. still standing. πŸ’œ


πŸ’€ BUGS πŸ’€

okay so the old versions were lowkey messy, we have receipts:

  • Before glibc 2.17, on certain architectures (e.g., x86, but not x86_64) expm1() raised a bogus underflow floating-point exception for some large negative x values (where the function result approaches -1). πŸ™ˆ
  • Before approximately glibc 2.11, expm1() raised a bogus invalid floating-point exception in addition to the expected overflow exception, and returned a NaN instead of positive infinity, for some large positive x values. πŸ’€
  • Before glibc 2.11, the glibc implementation did not set errno to ERANGE when a range error occurred.

all fixed now, glow-up complete, but iykyk.


🌈 SEE ALSO 🌈

exp(3), log(3), log1p(3)


that's the whole page bestie, you're officially an expm1 girlie πŸ’– sending you good vibes and accurate floating-point results, mwah πŸŽ€ this was Linux man-pages 6.20, dated 2026-02-08, and the page itself is expm1(3) β€” go forth and compute ✨

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