1LDEXP(3P)                  POSIX Programmer's Manual                 LDEXP(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

NAME

12       ldexp, ldexpf, ldexpl — load exponent of a floating-point number
13

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

36       Upon  successful  completion, these functions shall return x multiplied
37       by 2, raised to the power exp.
38
39       If these functions would cause overflow, a range error shall occur  and
40       ldexp(), ldexpf(), and ldexpl() shall return ±HUGE_VAL, ±HUGE_VALF, and
41       ±HUGE_VALL (according to the sign of x), respectively.
42
43       If the correct value would cause underflow, and is not representable, a
44       range error may occur, and ldexp(), ldexpf(), and ldexpl() shall return
45       0.0, or (if IEC 60559 Floating-Point is not supported)  an  implementa‐
46       tion-defined  value  no greater in magnitude than DBL_MIN, FLT_MIN, and
47       LDBL_MIN, respectively.
48
49       If x is NaN, a NaN shall be returned.
50
51       If x is ±0 or ±Inf, x shall be returned.
52
53       If exp is 0, x shall be returned.
54
55       If the correct value would cause underflow,  and  is  representable,  a
56       range error may occur and the correct value shall be returned.
57

ERRORS

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

EXAMPLES

82       None.
83

APPLICATION USAGE

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

RATIONALE

90       None.
91

FUTURE DIRECTIONS

93       None.
94

SEE ALSO

96       feclearexcept(), fetestexcept(), frexp(), isnan()
97
98       The Base Definitions volume of POSIX.1‐2017, Section 4.20, Treatment of
99       Error Conditions for Mathematical Functions, <math.h>
100
102       Portions of this text are reprinted and reproduced in  electronic  form
103       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
104       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
105       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
106       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
107       event of any discrepancy between this version and the original IEEE and
108       The Open Group Standard, the original IEEE and The Open Group  Standard
109       is  the  referee document. The original Standard can be obtained online
110       at http://www.opengroup.org/unix/online.html .
111
112       Any typographical or formatting errors that appear  in  this  page  are
113       most likely to have been introduced during the conversion of the source
114       files to man page format. To report such errors,  see  https://www.ker
115       nel.org/doc/man-pages/reporting_bugs.html .
116
117
118
119IEEE/The Open Group                  2017                            LDEXP(3P)
Impressum