EXP(3POSIX)

πŸ’– EXP(3POSIX) β€” the POSIX Programmer's Manual, bestie edition πŸ’–

okay so first thing's first, this page lives in the POSIX Programmer's Manual (that's the manual name, hi, hello πŸ‘‹), and you're reading the exp page. grab a strawberry πŸ“, we're doing math.

🌸 PROLOG 🌸

okay so heads up, this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ β€” so like, go consult the corresponding Linux manual page for details on Linux behavior β€” or honestly the interface might just not be implemented on Linux at all. no cap. πŸ’€


✨ NAME ✨

exp, expf, expl β€” the exponential function, aka the glow-up function πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <math.h>

double exp(double x);
float expf(float x);
long double expl(long double x);

three flavors, one vibe. pick your precision, queen πŸ‘‘

πŸŽ€ DESCRIPTION πŸŽ€

so the functionality described on this reference page is aligned with the ISO C standard. if there's any conflict between the requirements described here and the ISO C standard, that conflict is unintentional β€” this volume of POSIX.1‐2017 defers to the ISO C standard. periodt.

these functions shall compute the base-e exponential of x. that's it. that's the job. iconic.

now, if your application wants to check for error situations (and honestly, same, we should all be checking for error situations 😭), you should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. then on return, if errno is non-zero, or if fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero β€” boom, an error has occurred. that's the vibe check. ✨

🌈 RETURN VALUE 🌈

upon successful completion, these functions shall return the exponential value of x. slay.

  • if the correct value would cause overflow, a range error shall occur, and exp(), expf(), and expl() shall return the value of the macro HUGE_VAL, HUGE_VALF, and HUGE_VALL, respectively. big number energy. πŸ”₯
  • if the correct value would cause underflow and is not representable, a range error may occur, and exp(), expf(), and expl() shall return 0.0, or β€” if the IEC 60559 Floating-Point option is not supported β€” an implementation-defined value no greater in magnitude than DBL_MIN, FLT_MIN, and LDBL_MIN, respectively. tiny. microscopic. 🐜
  • if x is NaN, a NaN shall be returned.
  • if x is Β±0, 1 shall be returned.
  • if x is -Inf, +0 shall be returned.
  • if x is +Inf, 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. (so like, chill, they're not requirements, they're bonus content 🫢)

🧚 EXAMPLES 🧚

Computing the Density of the Standard Normal Distribution

this function shows an implementation for the density of the standard normal distribution using exp(). this example uses the constant M_PI, which is part of the XSI option. iykyk.

#include <math.h>

double
normal_density (double x)
{
    return exp(-x*x/2) / sqrt (2*M_PI);
}

look at her go. bell curve queen πŸ‘‘πŸ””

⭐ 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. they're independent but they're not that independent, you know? 🀝

πŸ’« RATIONALE πŸ’«

None. (she said nothing. silence. mysterious. main character energy. πŸ™ˆ)

πŸŒ™ FUTURE DIRECTIONS πŸŒ™

None. (no notes. perfect as she is. periodt.)

πŸ” SEE ALSO πŸ”

  • feclearexcept()
  • fetestexcept()
  • isnan()
  • log()

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!! this one came to you courtesy of IEEE/The Open Group, 2017 β€” yeah, 2017, she's vintage but she still ate πŸ’–βœ¨πŸŽ€