Debian Codegraph @

upstream/debian-unstable/man3/frexp.3

raw
1 '\" t
2 .\" Copyright 1993, David Metcalfe <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH frexp 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 frexp, frexpf, frexpl \- convert floating-point number to fractional
10 and integral components
11 .SH LIBRARY
12 Math library
13 .RI ( libm ,\~ \-lm )
14 .SH SYNOPSIS
15 .nf
16 .B #include <math.h>
17 .P
18 .BI "double frexp(double " x ", int *" e );
19 .BI "float frexpf(float " x ", int *" e );
20 .BI "long double frexpl(long double " x ", int *" e );
21 .fi
22 .P
23 .RS -4
24 Feature Test Macro Requirements for glibc (see
25 .BR feature_test_macros (7)):
26 .RE
27 .P
28 .BR frexpf (),
29 .BR frexpl ():
30 .nf
31 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
32 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
33 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
34 .fi
35 .SH DESCRIPTION
36 These functions are used to split the number
37 .I x
38 into a
39 normalized fraction and an exponent which is stored in
40 .IR e .
41 .SH RETURN VALUE
42 These functions return the normalized fraction.
43 If the argument
44 .I x
45 is not zero,
46 the normalized fraction is
47 .I x
48 times a power of two,
49 and its absolute value is always in the range 1/2 (inclusive) to
50 1 (exclusive), that is, [0.5,1).
51 .P
52 If
53 .I x
54 is zero, then the normalized fraction is
55 zero and zero is stored in
56 .IR e .
57 .P
58 If
59 .I x
60 is a NaN,
61 a NaN is returned, and the value of
62 .I *e
63 is unspecified.
64 .P
65 If
66 .I x
67 is positive infinity (negative infinity),
68 positive infinity (negative infinity) is returned, and the value of
69 .I *e
70 is unspecified.
71 .SH ERRORS
72 No errors occur.
73 .SH ATTRIBUTES
74 For an explanation of the terms used in this section, see
75 .BR attributes (7).
76 .TS
77 allbox;
78 lbx lb lb
79 l l l.
80 Interface Attribute Value
81 T{
82 .na
83 .nh
84 .BR frexp (),
85 .BR frexpf (),
86 .BR frexpl ()
87 T} Thread safety MT-Safe
88 .TE
89 .SH STANDARDS
90 C11, POSIX.1-2008.
91 .SH HISTORY
92 C99, POSIX.1-2001.
93 .P
94 The variant returning
95 .I double
96 also conforms to
97 SVr4, 4.3BSD, C89.
98 .SH EXAMPLES
99 The program below produces results such as the following:
100 .P
101 .in +4n
102 .EX
103 .RB "$" " ./a.out 2560"
104 frexp(2560, &e) = 0.625: 0.625 * 2\[ha]12 = 2560
105 .RB "$" " ./a.out \-4"
106 frexp(\-4, &e) = \-0.5: \-0.5 * 2\[ha]3 = \-4
107 .EE
108 .in
109 .SS Program source
110 \&
111 .\" SRC BEGIN (frexp.c)
112 .EX
113 #include <float.h>
114 #include <math.h>
115 #include <stdio.h>
116 #include <stdlib.h>
117 \&
118 int
119 main(int argc, char *argv[])
120 {
121 double x, r;
122 int e;
123 \&
124 x = strtod(argv[1], NULL);
125 r = frexp(x, &e);
126 \&
127 printf("frexp(%g, &e) = %g: %g * %d\[ha]%d = %g\[rs]n", x, r, r, 2, e, x);
128 exit(EXIT_SUCCESS);
129 }
130 .EE
131 .\" SRC END
132 .SH SEE ALSO
133 .BR ldexp (3),
134 .BR modf (3)