scalb(3)

πŸ’… scalb(3) β€” bestie, it's giving "obsolete but iconic"

okay so real talk: this page is for scalb, scalbf, and scalbl, and the girls are OBSOLETE. Like, the NAME line literally says so. But we still respect them, so here's everything, no gatekeeping. 🫢

πŸ“š LIBRARY

Math library β€” you link it with -lm, obviously. πŸ’–


✨ SYNOPSIS ✨

#include <math.h>

[[deprecated]] double scalb(double x, double e);
[[deprecated]] float scalbf(float x, float e);
[[deprecated]] long double scalbl(long double x, long double e);

πŸ‘€ notice all three of them carry the [[deprecated]] tag. they know.

🧚 Feature Test Macro Requirements for glibc (like, go read feature_test_macros(7) bestie)

scalb():

_XOPEN_SOURCE >= 500
    || /* Since glibc 2.19: */ _DEFAULT_SOURCE
    || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

scalbf(), scalbl():

_XOPEN_SOURCE >= 600
    || /* Since glibc 2.19: */ _DEFAULT_SOURCE
    || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

🌸 DESCRIPTION 🌸

so these functions take your first argument x and multiply it by FLT_RADIX (which is probably 2, iykyk) raised to the power of e. in math-girl terms:

x * FLT_RADIX ** e

and if you wanna know what FLT_RADIX actually is on your machine, just #include <float.h> and it will tell you. slay. ✨


πŸ’– RETURN VALUE πŸ’–

  • On success? You get x * FLT_RADIX ** e. that's the whole dream. πŸŽ€
  • If x or e is a NaN, a NaN comes back. not me getting NaN back 😭
  • If x is positive infinity (negative infinity), and e is not negative infinity, then positive infinity (negative infinity) is returned. πŸ‘‘
  • If x is +0 (-0), and e is not positive infinity, you get +0 (-0). the sign is preserved, periodt.
  • If x is zero, and e is positive infinity β€” domain error, and a NaN is returned. πŸ’€
  • If x is an infinity, and e is negative infinity β€” domain error, and a NaN is returned. πŸ’€
  • If the result overflows, it's a range error, and these functions return HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively β€” with a sign the same as x. πŸ”₯
  • If the result underflows, it's a range error, and the functions return zero, with a sign the same as x. πŸ¦‹

🚨 ERRORS 🚨

how do you even know if something went sideways? go read math_error(7), she explains the whole detecting-errors thing.

here's what can happen:

  • Domain error: x is 0, and e is positive infinity, or x is positive infinity and e is negative infinity and the other argument is not a NaN β€” errno gets set to EDOM, and an invalid floating-point exception (FE_INVALID) is raised. πŸ™ˆ
  • Range error, overflow β€” errno gets set to ERANGE, and an overflow floating-point exception (FE_OVERFLOW) is raised. 🌈
  • Range error, underflow β€” errno gets set to ERANGE, and an underflow floating-point exception (FE_UNDERFLOW) is raised. πŸ’œ

πŸ‘‘ ATTRIBUTES πŸ‘‘

if the vocab in this section is confusing you, attributes(7) has the glossary, bestie.

  • scalb(), scalbf(), scalbl() β€” Thread safety: MT-Safe. she's safe to share, no cap. 🫢

⭐ STANDARDS ⭐

None.

...yeah. that's it. that's the whole section. πŸ’€


πŸ•°οΈ HISTORY πŸ•°οΈ

scalb()

  • 4.3BSD.
  • Obsolescent in POSIX.1-2001.
  • Removed in POSIX.1-2008, which recommended using scalbln(3), scalblnf(3), or scalblnl(3) instead. (basically: she got gently retired and they handed her job to her cousins. respecting the legacy tho. πŸŽ€)

πŸ› BUGS πŸ›

Before glibc 2.20, these functions did not set errno for domain and range errors. so if you were checking errno back in the day... yeah, nothing was there. 😭


πŸ¦‹ SEE ALSO πŸ¦‹


quick vibe check: this whole page is about functions that are literally marked [[deprecated]] and got removed from POSIX.1-2008. use them if you must, but the recommended glow-up is scalbln(3) / scalblnf(3) / scalblnl(3). πŸ’…

<style>okay that's the whole page!!</style> written up in Linux man-pages 6.20, dated 2026-02-08, and yes the page you just read is scalb(3). mwah, go touch some floating point πŸ§šβœ¨πŸ’–

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