1LDEXP(3P) POSIX Programmer's Manual LDEXP(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
11
13 ldexp, ldexpf, ldexpl — load exponent of a floating-point number
14
16 #include <math.h>
17
18 double ldexp(double x, int exp);
19 float ldexpf(float x, int exp);
20 long double ldexpl(long double x, int exp);
21
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 quantity x * 2exp.
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
37 Upon successful completion, these functions shall return x multiplied
38 by 2, raised to the power exp.
39
40 If these functions would cause overflow, a range error shall occur and
41 ldexp(), ldexpf(), and ldexpl() shall return ±HUGE_VAL, ±HUGE_VALF, and
42 ±HUGE_VALL (according to the sign of x), respectively.
43
44 If the correct value would cause underflow, and is not representable, a
45 range error may occur, and ldexp(), ldexpf(), and ldexpl() shall return
46 0.0, or (if IEC 60559 Floating-Point is not supported) an implementa‐
47 tion-defined value no greater in magnitude than DBL_MIN, FLT_MIN, and
48 LDBL_MIN, respectively.
49
50 If x is NaN, a NaN shall be returned.
51
52 If x is ±0 or ±Inf, x shall be returned.
53
54 If exp is 0, x shall be returned.
55
56 If the correct value would cause underflow, and is representable, a
57 range error may occur and the correct value shall be returned.
58
60 These functions shall fail if:
61
62 Range Error The result overflows.
63
64 If the integer expression (math_errhandling & MATH_ERRNO)
65 is non-zero, then errno shall be set to [ERANGE]. If the
66 integer expression (math_errhandling & MATH_ERREXCEPT) is
67 non-zero, then the overflow floating-point exception shall
68 be raised.
69
70 These functions may fail if:
71
72 Range Error The result underflows.
73
74 If the integer expression (math_errhandling & MATH_ERRNO)
75 is non-zero, then errno shall be set to [ERANGE]. If the
76 integer expression (math_errhandling & MATH_ERREXCEPT) is
77 non-zero, then the underflow floating-point exception shall
78 be raised.
79
80 The following sections are informative.
81
83 None.
84
86 On error, the expressions (math_errhandling & MATH_ERRNO) and
87 (math_errhandling & MATH_ERREXCEPT) are independent of each other, but
88 at least one of them must be non-zero.
89
91 None.
92
94 None.
95
97 feclearexcept(), fetestexcept(), frexp(), isnan()
98
99 The Base Definitions volume of POSIX.1‐2008, Section 4.19, Treatment of
100 Error Conditions for Mathematical Functions, <math.h>
101
103 Portions of this text are reprinted and reproduced in electronic form
104 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
105 -- Portable Operating System Interface (POSIX), The Open Group Base
106 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
107 cal and Electronics Engineers, Inc and The Open Group. (This is
108 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
109 event of any discrepancy between this version and the original IEEE and
110 The Open Group Standard, the original IEEE and The Open Group Standard
111 is the referee document. The original Standard can be obtained online
112 at http://www.unix.org/online.html .
113
114 Any typographical or formatting errors that appear in this page are
115 most likely to have been introduced during the conversion of the source
116 files to man page format. To report such errors, see https://www.ker‐
117 nel.org/doc/man-pages/reporting_bugs.html .
118
119
120
121IEEE/The Open Group 2013 LDEXP(3P)