share/mk/: Fix includes
[man-pages.git] / man3 / frexp.3
blob16ece267d6225225d9507e72a01e42b6189396d3
1 '\" t
2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" References consulted:
7 .\"     Linux libc source code
8 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
9 .\"     386BSD man pages
10 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
11 .\" Modified 2002-07-27 by Walter Harms
12 .\"     (walter.harms@informatik.uni-oldenburg.de)
13 .\"
14 .TH frexp 3 (date) "Linux man-pages (unreleased)"
15 .SH NAME
16 frexp, frexpf, frexpl \- convert floating-point number to fractional
17 and integral components
18 .SH LIBRARY
19 Math library
20 .RI ( libm ", " \-lm )
21 .SH SYNOPSIS
22 .nf
23 .B #include <math.h>
25 .BI "double frexp(double " x ", int *" exp );
26 .BI "float frexpf(float " x ", int *" exp );
27 .BI "long double frexpl(long double " x ", int *" exp );
28 .fi
30 .RS -4
31 Feature Test Macro Requirements for glibc (see
32 .BR feature_test_macros (7)):
33 .RE
35 .BR frexpf (),
36 .BR frexpl ():
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 are used to split the number
44 .I x
45 into a
46 normalized fraction and an exponent which is stored in
47 .IR exp .
48 .SH RETURN VALUE
49 These functions return the normalized fraction.
50 If the argument
51 .I x
52 is not zero,
53 the normalized fraction is
54 .I x
55 times a power of two,
56 and its absolute value is always in the range 1/2 (inclusive) to
57 1 (exclusive), that is, [0.5,1).
60 .I x
61 is zero, then the normalized fraction is
62 zero and zero is stored in
63 .IR exp .
66 .I x
67 is a NaN,
68 a NaN is returned, and the value of
69 .I *exp
70 is unspecified.
73 .I x
74 is positive infinity (negative infinity),
75 positive infinity (negative infinity) is returned, and the value of
76 .I *exp
77 is unspecified.
78 .SH ERRORS
79 No errors occur.
80 .SH ATTRIBUTES
81 For an explanation of the terms used in this section, see
82 .BR attributes (7).
83 .TS
84 allbox;
85 lbx lb lb
86 l l l.
87 Interface       Attribute       Value
89 .na
90 .nh
91 .BR frexp (),
92 .BR frexpf (),
93 .BR frexpl ()
94 T}      Thread safety   MT-Safe
95 .TE
96 .SH STANDARDS
97 C11, POSIX.1-2008.
98 .SH HISTORY
99 C99, POSIX.1-2001.
101 The variant returning
102 .I double
103 also conforms to
104 SVr4, 4.3BSD, C89.
105 .SH EXAMPLES
106 The program below produces results such as the following:
108 .in +4n
110 .RB "$" " ./a.out 2560"
111 frexp(2560, &e) = 0.625: 0.625 * 2\[ha]12 = 2560
112 .RB "$" " ./a.out \-4"
113 frexp(\-4, &e) = \-0.5: \-0.5 * 2\[ha]3 = \-4
116 .SS Program source
118 .\" SRC BEGIN (frexp.c)
120 #include <float.h>
121 #include <math.h>
122 #include <stdio.h>
123 #include <stdlib.h>
126 main(int argc, char *argv[])
128     double x, r;
129     int exp;
131     x = strtod(argv[1], NULL);
132     r = frexp(x, &exp);
134     printf("frexp(%g, &e) = %g: %g * %d\[ha]%d = %g\en", x, r, r, 2, exp, x);
135     exit(EXIT_SUCCESS);
138 .\" SRC END
139 .SH SEE ALSO
140 .BR ldexp (3),
141 .BR modf (3)