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