SCALBLN(3POSIX)

πŸ’– SCALBLN(3POSIX) β€” the POSIX Programmer's Manual, but make it cute πŸ’–

okay bestie, welcome to the POSIX Programmer's Manual entry for all the scalbln girlies 🫢 this is the version where math functions get main character energy.


✨ PROLOG ✨ (the lil disclaimer, don't skip it)

This manual page is part of the POSIX Programmer's Manual. Heads up though β€” the Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the deets on Linux behavior), or the interface might not even be implemented on Linux at all. πŸ’€ no cap, always check.


🌸 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 β€” fr fr, no beef intended. This volume of POSIX.1‐2017 defers to the ISO C standard. πŸ‘‘

These functions shall compute x * FLT_RADIXn efficiently, not normally by computing FLT_RADIXn explicitly. So like, they get you there the smart way instead of doing the whole FLT_RADIXn thing out in the open. efficiency slay ✨

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. that's your vibe check 🚨


πŸ’… RETURN VALUE πŸ’…

Upon successful completion, these functions shall return x * FLT_RADIXn. periodt.

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.

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.

If x is NaN, a NaN shall be returned. (NaN stays NaN, iconic behavior tbh πŸ™ˆ)

If x is Β±0 or Β±Inf, x shall be returned.

If n is 0, x shall 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, then errno shall be set to [ERANGE]. If the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the overflow floating-point exception shall be raised.

These functions may fail if:

  • Range Error β€” The result underflows.
    • If the integer expression (math_errhandling & MATH_ERRNO) is non-zero, then errno shall be set to [ERANGE]. If the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow floating-point exception shall be raised.

The following sections are informative. (translation: the vibes continue, but the hard requirements stop here πŸ’–)


🌈 EXAMPLES 🌈

None. yeah bestie, they really said "no examples, figure it out" 😭 the audacity honestly.


πŸ’œ APPLICATION USAGE πŸ’œ

On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other, but at least one of them must be non-zero. so they're doing their own separate things, but like, one of them HAS to show up. 🫢


⭐ RATIONALE ⭐

These functions are named so as to avoid conflicting with the historical definition of the scalb() function from the Single UNIX Specification. The difference is that the scalb() function has a second argument of double instead of int. The scalb() function 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 like, int literally cannot hold the number on a lot of systems and that's why the long girlies exist. they ate that. πŸ‘‘


🧚 FUTURE DIRECTIONS 🧚

None. the future is empty, the future is now, nothing is coming. πŸ’€


πŸ’– SEE ALSO πŸ’–

  • feclearexcept()
  • fetestexcept()
  • The Base Definitions volume of POSIX.1‐2017, Section 4.20, Treatment of Error Conditions for Mathematical Functions, <math.h>

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, every last detail preserved, nothing dropped, we keep the facts and serve the vibe πŸ’…

signing off with love from IEEE/The Open Group, 2017 β€” mwah, go scale some exponents πŸ¦‹βœ¨πŸ’–