1EXP2(P) POSIX Programmer's Manual EXP2(P)
2
3
4
6 exp2, exp2f, exp2l - exponential base 2 functions
7
9 #include <math.h>
10
11 double exp2(double x);
12 float exp2f(float x);
13 long double exp2l(long double x);
14
15
17 These functions shall compute the base-2 exponential of x.
18
19 An application wishing to check for error situations should set errno
20 to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these
21 functions. On return, if errno is non-zero or fetestexcept(FE_INVALID
22 | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
23 occurred.
24
26 Upon successful completion, these functions shall return 2**x.
27
28 If the correct value would cause overflow, a range error shall occur
29 and exp2(), exp2f(), and exp2l() shall return the value of the macro
30 HUGE_VAL, HUGE_VALF, and HUGE_VALL, respectively.
31
32 If the correct value would cause underflow, and is not representable, a
33 range error may occur, and either 0.0 (if supported), or an imple‐
34 mentation-defined value shall be returned.
35
36 If x is NaN, a NaN shall be returned.
37
38 If x is ±0, 1 shall be returned.
39
40 If x is -Inf, +0 shall be returned.
41
42 If x is +Inf, x shall be returned.
43
44 If the correct value would cause underflow, and is representable, a
45 range error may occur and the correct value shall be returned.
46
48 These functions shall fail if:
49
50 Range Error
51 The result overflows.
52
53 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
54 then errno shall be set to [ERANGE]. If the integer expression
55 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the overflow
56 floating-point exception shall be raised.
57
58
59 These functions may fail if:
60
61 Range Error
62 The result underflows.
63
64 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
65 then errno shall be set to [ERANGE]. If the integer expression
66 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow
67 floating-point exception shall be raised.
68
69
70 The following sections are informative.
71
73 None.
74
76 For IEEE Std 754-1985 double, 1024 <= x implies exp2( x) has over‐
77 flowed. The value x < -1022 implies exp( x) has underflowed.
78
79 On error, the expressions (math_errhandling & MATH_ERRNO) and
80 (math_errhandling & MATH_ERREXCEPT) are independent of each other, but
81 at least one of them must be non-zero.
82
84 None.
85
87 None.
88
90 exp() , feclearexcept() , fetestexcept() , isnan() , log() , the Base
91 Definitions volume of IEEE Std 1003.1-2001, Section 4.18, Treatment of
92 Error Conditions for Mathematical Functions, <math.h>
93
95 Portions of this text are reprinted and reproduced in electronic form
96 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
97 -- Portable Operating System Interface (POSIX), The Open Group Base
98 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
99 Electrical and Electronics Engineers, Inc and The Open Group. In the
100 event of any discrepancy between this version and the original IEEE and
101 The Open Group Standard, the original IEEE and The Open Group Standard
102 is the referee document. The original Standard can be obtained online
103 at http://www.opengroup.org/unix/online.html .
104
105
106
107IEEE/The Open Group 2003 EXP2(P)