1EXP(3P)                    POSIX Programmer's Manual                   EXP(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       exp, expf, expl — exponential function
14

SYNOPSIS

16       #include <math.h>
17
18       double exp(double x);
19       float expf(float x);
20       long double expl(long double x);
21

DESCRIPTION

23       The functionality described on this reference page is aligned with  the
24       ISO C  standard.  Any  conflict between the requirements described here
25       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2008
26       defers to the ISO C standard.
27
28       These functions shall compute the base-e exponential of x.
29
30       An  application  wishing to check for error situations should set errno
31       to zero and  call  feclearexcept(FE_ALL_EXCEPT)  before  calling  these
32       functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
33       FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero,  an  error  has
34       occurred.
35

RETURN VALUE

37       Upon  successful  completion, these functions shall return the exponen‐
38       tial value of x.
39
40       If the correct value would cause overflow, a range  error  shall  occur
41       and  exp(),  expf(),  and  expl()  shall  return the value of the macro
42       HUGE_VAL, HUGE_VALF, and HUGE_VALL, respectively.
43
44       If the correct value would cause underflow, and is not representable, a
45       range  error may occur, and exp(), expf(), and expl() shall return 0.0,
46       or (if the IEC 60559 Floating-Point option is not supported) an  imple‐
47       mentation-defined  value no greater in magnitude than DBL_MIN, FLT_MIN,
48       and LDBL_MIN, respectively.
49
50       If x is NaN, a NaN shall be returned.
51
52       If x is ±0, 1 shall be returned.
53
54       If x is −Inf, +0 shall be returned.
55
56       If x is +Inf, x shall be returned.
57
58       If the correct value would cause underflow,  and  is  representable,  a
59       range error may occur and the correct value shall be returned.
60

ERRORS

62       These functions shall fail if:
63
64       Range Error The result overflows.
65
66                   If  the  integer expression (math_errhandling & MATH_ERRNO)
67                   is non-zero, then errno shall be set to [ERANGE].   If  the
68                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
69                   non-zero, then the overflow floating-point exception  shall
70                   be raised.
71
72       These functions may fail if:
73
74       Range Error The result underflows.
75
76                   If  the  integer expression (math_errhandling & MATH_ERRNO)
77                   is non-zero, then errno shall be set to [ERANGE].   If  the
78                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
79                   non-zero, then the underflow floating-point exception shall
80                   be raised.
81
82       The following sections are informative.
83

EXAMPLES

85   Computing the Density of the Standard Normal Distribution
86       This  function  shows an implementation for the density of the standard
87       normal distribution using exp().  This example uses the  constant  M_PI
88       which is part of the XSI option.
89
90           #include <math.h>
91
92           double
93           normal_density (double x)
94           {
95               return exp(−x*x/2) / sqrt (2*M_PI);
96           }
97

APPLICATION USAGE

99       Note  that  for  IEEE Std 754‐1985 double, 709.8 < x implies exp(x) has
100       overflowed. The value x< −708.4 implies exp(x) has underflowed.
101
102       On  error,  the  expressions  (math_errhandling   &   MATH_ERRNO)   and
103       (math_errhandling  & MATH_ERREXCEPT) are independent of each other, but
104       at least one of them must be non-zero.
105

RATIONALE

107       None.
108

FUTURE DIRECTIONS

110       None.
111

SEE ALSO

113       feclearexcept(), fetestexcept(), isnan(), log()
114
115       The Base Definitions volume of POSIX.1‐2008, Section 4.19, Treatment of
116       Error Conditions for Mathematical Functions, <math.h>
117
119       Portions  of  this text are reprinted and reproduced in electronic form
120       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
121       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
122       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
123       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
124       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
125       event of any discrepancy between this version and the original IEEE and
126       The Open Group Standard, the original IEEE and The Open Group  Standard
127       is  the  referee document. The original Standard can be obtained online
128       at http://www.unix.org/online.html .
129
130       Any typographical or formatting errors that appear  in  this  page  are
131       most likely to have been introduced during the conversion of the source
132       files to man page format. To report such errors,  see  https://www.ker
133       nel.org/doc/man-pages/reporting_bugs.html .
134
135
136
137IEEE/The Open Group                  2013                              EXP(3P)
Impressum