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