Debian Codegraph @

upstream/debian-trixie/man3/ldexp.3

raw
1 '\" t
2 .\" Copyright 1993 David Metcalfe ([email protected])
3 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
4 .\" <[email protected]>
5 .\"
6 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\"
8 .\" References consulted:
9 .\" Linux libc source code
10 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
11 .\" 386BSD man pages
12 .\" Modified 1993-07-24 by Rik Faith ([email protected])
13 .\" Modified 2004-10-31 by aeb
14 .\"
15 .TH ldexp 3 2024-05-02 "Linux man-pages 6.9.1"
16 .SH NAME
17 ldexp, ldexpf, ldexpl \- multiply floating-point number by integral power of 2
18 .SH LIBRARY
19 Math library
20 .RI ( libm ", " \-lm )
21 .SH SYNOPSIS
22 .nf
23 .B #include <math.h>
24 .P
25 .BI "double ldexp(double " x ", int " exp );
26 .BI "float ldexpf(float " x ", int " exp );
27 .BI "long double ldexpl(long double " x ", int " exp );
28 .fi
29 .P
30 .RS -4
31 Feature Test Macro Requirements for glibc (see
32 .BR feature_test_macros (7)):
33 .RE
34 .P
35 .BR ldexpf (),
36 .BR ldexpl ():
37 .nf
38 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
39 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
40 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
41 .fi
42 .SH DESCRIPTION
43 These functions return the result of multiplying the floating-point number
44 .I x
45 by 2 raised to the power
46 .IR exp .
47 .SH RETURN VALUE
48 On success, these functions return
49 .IR "x * (2\[ha]exp)" .
50 .P
51 If
52 .I exp
53 is zero, then
54 .I x
55 is returned.
56 .P
57 If
58 .I x
59 is a NaN,
60 a NaN is returned.
61 .P
62 If
63 .I x
64 is positive infinity (negative infinity),
65 positive infinity (negative infinity) is returned.
66 .P
67 If the result underflows,
68 a range error occurs,
69 and zero is returned.
70 .P
71 If the result overflows,
72 a range error occurs,
73 and the functions return
74 .BR HUGE_VAL ,
75 .BR HUGE_VALF ,
76 or
77 .BR HUGE_VALL ,
78 respectively, with a sign the same as
79 .IR x .
80 .SH ERRORS
81 See
82 .BR math_error (7)
83 for information on how to determine whether an error has occurred
84 when calling these functions.
85 .P
86 The following errors can occur:
87 .TP
88 Range error, overflow
89 .I errno
90 is set to
91 .BR ERANGE .
92 An overflow floating-point exception
93 .RB ( FE_OVERFLOW )
94 is raised.
95 .TP
96 Range error, underflow
97 .I errno
98 is set to
99 .BR ERANGE .
100 An underflow floating-point exception
101 .RB ( FE_UNDERFLOW )
102 is raised.
103 .SH ATTRIBUTES
104 For an explanation of the terms used in this section, see
105 .BR attributes (7).
106 .TS
107 allbox;
108 lbx lb lb
109 l l l.
110 Interface Attribute Value
111 T{
112 .na
113 .nh
114 .BR ldexp (),
115 .BR ldexpf (),
116 .BR ldexpl ()
117 T} Thread safety MT-Safe
118 .TE
119 .SH STANDARDS
120 C11, POSIX.1-2008.
121 .SH HISTORY
122 C99, POSIX.1-2001.
123 .P
124 The variant returning
125 .I double
126 also conforms to
127 SVr4, 4.3BSD, C89.
128 .SH SEE ALSO
129 .BR frexp (3),
130 .BR modf (3),
131 .BR scalbln (3)