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(), andexpl()shall return the value of the macroHUGE_VAL,HUGE_VALF, andHUGE_VALL, respectively. big number energy. π₯ - if the correct value would cause underflow and is not representable, a range error may occur, and
exp(),expf(), andexpl()shall return0.0, or β if the IEC 60559 Floating-Point option is not supported β an implementation-defined value no greater in magnitude thanDBL_MIN,FLT_MIN, andLDBL_MIN, respectively. tiny. microscopic. π - if x is
NaN, aNaNshall be returned. - if x is
Β±0,1shall be returned. - if x is
-Inf,+0shall 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, 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. (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>
π 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!! this one came to you courtesy of IEEE/The Open Group, 2017 β yeah, 2017, she's vintage but she still ate πβ¨π
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms