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
eis zero, thenxis returned. (she said "i'm not doing anything today" and honestly, same ποΈ) - If
xis aNaN, aNaNis returned. NaN in, NaN out, the circle of life π - If
xis 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, orHUGE_VALL, respectively, with a sign the same asx. 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 β
errnois set toERANGE. An overflow floating-point exception (FE_OVERFLOW) is raised. π¨ - Range error, underflow β
errnois set toERANGE. 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 π
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
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms