ldexp(3)

✨ ldexp(3) ✨ β€” the manual page for ldexp, ldexpf, ldexpl πŸ’–

okay bestie, welcome to the glow-up zone πŸ¦‹ this is the page about ldexp, ldexpf, and ldexpl β€” three little math-library icons that take a floating-point number and scale it by a power of two. no cap, it's giving "scientific notation but make it binary" and honestly? obsessed.


🌸 NAME 🌸

ldexp, ldexpf, ldexpl β€” multiply floating-point number by integral power of 2 πŸ’…

πŸ“š LIBRARY πŸ“š

Math library (libm, -lm) β€” yes bestie, you have to link -lm. she does not come for free. πŸŽ€

🫢 SYNOPSIS 🫢

#include <math.h>

double ldexp(double x, int e);
float ldexpf(float x, int e);
long double ldexpl(long double x, int e);

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

ldexpf(), ldexpl():
    _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
        || /* Since glibc 2.19: */ _DEFAULT_SOURCE
        || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
fr fr, if you're on an older glibc and these macros stress you out, that's normal. you're doing amazing sweetie πŸ’œ

πŸ’– DESCRIPTION πŸ’–

so the way that these functions work is: they return the result of multiplying the floating-point number x by 2 raised to the power e. that's it. that's the whole vibe. ✨

πŸ”₯ RETURN VALUE πŸ”₯

  • On success, these functions return x * (2^e). iconic behavior, no notes. πŸ‘‘
  • If e is zero, then x is returned. (she said "i'm not doing anything today" and honestly, same πŸ›‹οΈ)
  • If x is a NaN, a NaN is returned. NaN in, NaN out, the circle of life 🌈
  • If x is positive infinity (negative infinity), positive infinity (negative infinity) is returned. she keeps her sign, as she should πŸ’…
  • 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, with a sign the same as x. she went TOO big and now she's HUGE πŸ’€

😭 ERRORS 😭

See math_error(7) for information on how to determine whether an error has occurred when calling these functions.

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. 🚨

πŸŽ€ ATTRIBUTES πŸŽ€

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

  • Interface: ldexp(), ldexpf(), ldexpl() β€” Attribute: Thread safety β€” Value: MT-Safe βœ…

(translation: she is safe to share across threads, bestie, go forth and multithread 🧡✨)

⭐ STANDARDS ⭐

C11, POSIX.1-2008. certified, stamped, official. πŸ’–

🌈 HISTORY 🌈

C99, POSIX.1-2001.

The variant returning double also conforms to SVr4, 4.3BSD, C89. she's been around, she's got lore πŸ“œ

πŸ‘€ SEE ALSO πŸ‘€

frexp(3), modf(3), scalbln(3)


and that's the whole page, bestie!! 🫢 this came to you via Linux man-pages 6.20, dated 2026-02-08. go multiply something by a power of two and slay πŸ’…βœ¨πŸŒΈ

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