SCALBLN(3P)
π SCALBLN(3P) π compute exponent using FLT_RADIX π¦
okay bestie, welcome to the SCALBLN(3P) page from the POSIX Programmer's Manual β yes, the whole family, scalbln, scalblnf, scalblnl, scalbn, scalbnf, scalbnl. it's giving "one job, six spellings" and honestly? iconic. let's get into it π
β¨ PROLOG β¨
so this manual page is part of the POSIX Programmer's Manual, periodt. and listen β the Linux implementation of this interface may differ from what's written here (so pls go consult the corresponding Linux manual page for the details of Linux behavior), or the interface might not even be implemented on Linux at all. lowkey important, don't skip it π
πΈ NAME πΈ
scalbln, scalblnf, scalblnl, scalbn, scalbnf, scalbnl β compute exponent using FLT_RADIX π«
π SYNOPSIS π
#include <math.h>
double scalbln(double x, long n);
float scalblnf(float x, long n);
long double scalblnl(long double x, long n);
double scalbn(double x, int n);
float scalbnf(float x, int n);
long double scalbnl(long double x, int n);
π DESCRIPTION π
the functionality described on this reference page is aligned with the ISO C standard. any conflict between the requirements described here and the ISO C standard is unintentional β nobody's fighting, it's just a paperwork thing. this volume of POSIX.1β2017 defers to the ISO C standard. π
these functions shall compute x * FLT_RADIX^n efficiently (that's x times FLT_RADIX raised to the n) β and not normally by computing FLT_RADIX^n explicitly. efficient queen behavior fr fr β¨
an application wishing to check for error situations should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. then, on return, if errno is non-zero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred. vibe check complete π
π«Ά RETURN VALUE π«Ά
upon successful completion, these functions shall return x * FLT_RADIX^n.
if the result would cause overflow, a range error shall occur and these functions shall return Β±HUGE_VAL, Β±HUGE_VALF, and Β±HUGE_VALL (according to the sign of x) as appropriate for the return type of the function. big number, big drama π₯
if the correct value would cause underflow, and is not representable, a range error may occur, and scalbln(), scalblnf(), scalblnl(), scalbn(), scalbnf(), and scalbnl() shall return 0.0, or (if IEC 60559 Floating-Point is not supported) an implementation-defined value no greater in magnitude than DBL_MIN, FLT_MIN, LDBL_MIN, DBL_MIN, FLT_MIN, and LDBL_MIN, respectively. yes those are in that exact order, matching the function list one-for-one, no cap π§
- if
xis NaN, a NaN shall be returned. - if
xisΒ±0orΒ±Inf,xshall be returned. - if
nis0,xshall be returned. - if the correct value would cause underflow, and is representable, a range error may occur and the correct value shall be returned.
π ERRORS π
these functions shall fail if:
- Range Error β the result overflows.
- if the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[ERANGE]. - if the integer expression
(math_errhandling & MATH_ERREXCEPT)is non-zero, then the overflow floating-point exception shall be raised.
- if the integer expression
these functions may fail if:
- Range Error β the result underflows.
- if the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[ERANGE]. - if the integer expression
(math_errhandling & MATH_ERREXCEPT)is non-zero, then the underflow floating-point exception shall be raised.
- if the integer expression
the following sections are informative. that means they're the tea, not the rules β
π EXAMPLES π
None. bestie there is literally nothing here. no examples. we move π
π APPLICATION USAGE π
on error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERRERXCEPT)... okay no, let me not do that to you β it's (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT), and they are independent of each other, but at least one of them must be non-zero. so like, they don't talk, but they both have to show up to the party π
β RATIONALE β
so why these names? because they wanted to avoid conflicting with the historical definition of the scalb() function from the Single UNIX Specification. the difference? scalb() has a second argument of double instead of int. and plot twist: scalb() is not part of the ISO C standard. π
the three functions whose second type is long are provided because the factor required to scale from the smallest positive floating-point value to the largest finite one, on many implementations, is too large to represent in the minimum-width int format. so they gave it a long. ate and left no crumbs π
π¦ FUTURE DIRECTIONS π¦
None. nothing coming. the future is quiet, bestie. we love a stable API π
π SEE ALSO π
feclearexcept()fetestexcept()
and from The Base Definitions volume of POSIX.1β2017: Section 4.20, Treatment of Error Conditions for Mathematical Functions, and <math.h> β¨
π COPYRIGHT π
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html . π
and that's the whole page, bestie β brought to you by IEEE/The Open Group, dated 2017, and it's the SCALBLN(3P) page, exactly as it was. go forth and scale responsibly π«Άπ
β¨
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- 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-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms