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
12 ldexp, ldexpf, ldexpl - load exponent of a floating-point number
13
15 #include <math.h>
16
17 double ldexp(double x, int exp);
18 float ldexpf(float x, int exp);
19 long double ldexpl(long double x, int exp);
20
21
23 These functions shall compute the quantity x * 2**exp.
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 x multiplied
33 by 2, raised to the power exp.
34
35 If these functions would cause overflow, a range error shall occur and
36 ldexp(), ldexpf(), and ldexpl() shall return ±HUGE_VAL, ±HUGE_VALF, and
37 ±HUGE_VALL (according to the sign of x), respectively.
38
39 If the correct value would cause underflow, and is not representable, a
40 range error may occur, and either 0.0 (if supported), or an implemen‐
41 tation-defined value shall be returned.
42
43 If x is NaN, a NaN shall be returned.
44
45 If x is ±0 or ±Inf, x shall be returned.
46
47 If exp is 0, x shall be returned.
48
49 If the correct value would cause underflow, and is representable, a
50 range error may occur and the correct value shall be returned.
51
53 These functions shall fail if:
54
55 Range Error
56 The result overflows.
57
58 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
59 then errno shall be set to [ERANGE]. If the integer expression
60 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the overflow
61 floating-point exception shall be raised.
62
63
64 These functions may fail if:
65
66 Range Error
67 The result underflows.
68
69 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
70 then errno shall be set to [ERANGE]. If the integer expression
71 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow
72 floating-point exception shall be raised.
73
74
75 The following sections are informative.
76
78 None.
79
81 On error, the expressions (math_errhandling & MATH_ERRNO) and
82 (math_errhandling & MATH_ERREXCEPT) are independent of each other, but
83 at least one of them must be non-zero.
84
86 None.
87
89 None.
90
92 feclearexcept(), fetestexcept(), frexp(), isnan(), the Base Definitions
93 volume of IEEE Std 1003.1-2001, Section 4.18, Treatment of Error Condi‐
94 tions for Mathematical Functions, <math.h>
95
97 Portions of this text are reprinted and reproduced in electronic form
98 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
99 -- Portable Operating System Interface (POSIX), The Open Group Base
100 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
101 Electrical and Electronics Engineers, Inc and The Open Group. In the
102 event of any discrepancy between this version and the original IEEE and
103 The Open Group Standard, the original IEEE and The Open Group Standard
104 is the referee document. The original Standard can be obtained online
105 at http://www.opengroup.org/unix/online.html .
106
107
108
109IEEE/The Open Group 2003 LDEXP(3P)