OSDN Git Service

(split) LDP_man-pages: update original to v3.34.
[linuxjm/LDP_man-pages.git] / original / man3 / frexp.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\"     386BSD man pages
27 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified 2002-07-27 by Walter Harms
29 .\"     (walter.harms@informatik.uni-oldenburg.de)
30 .\"
31 .TH FREXP 3 2010-09-20 "" "Linux Programmer's Manual"
32 .SH NAME
33 frexp, frexpf, frexpl \- convert floating-point number to fractional
34 and integral components
35 .SH SYNOPSIS
36 .nf
37 .B #include <math.h>
38 .sp
39 .BI "double frexp(double " x ", int *" exp );
40 .br
41 .BI "float frexpf(float " x ", int *" exp );
42 .br
43 .BI "long double frexpl(long double " x ", int *" exp );
44 .fi
45 .sp
46 Link with \fI\-lm\fP.
47 .sp
48 .in -4n
49 Feature Test Macro Requirements for glibc (see
50 .BR feature_test_macros (7)):
51 .in
52 .sp
53 .ad l
54 .BR frexpf (),
55 .BR frexpl ():
56 .RS 4
57 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
58 _POSIX_C_SOURCE\ >=\ 200112L;
59 .br
60 or
61 .I cc\ -std=c99
62 .RE
63 .ad
64 .SH DESCRIPTION
65 The
66 .BR frexp ()
67 function is used to split the number \fIx\fP into a
68 normalized fraction and an exponent which is stored in \fIexp\fP.
69 .SH "RETURN VALUE"
70 The
71 .BR frexp ()
72 function returns the normalized fraction.
73 If the argument \fIx\fP is not zero,
74 the normalized fraction is \fIx\fP times a power of two,
75 and its absolute value is always in the range 1/2 (inclusive) to
76 1 (exclusive), that is, [0.5,1).
77
78 If \fIx\fP is zero, then the normalized fraction is
79 zero and zero is stored in \fIexp\fP.
80
81 If
82 .I x
83 is a NaN,
84 a NaN is returned, and the value of
85 .I *exp
86 is unspecified.
87
88 If
89 .I x
90 is positive infinity (negative infinity),
91 positive infinity (negative infinity) is returned, and the value of
92 .I *exp
93 is unspecified.
94 .SH ERRORS
95 No errors occur.
96 .SH "CONFORMING TO"
97 C99, POSIX.1-2001.
98 The variant returning
99 .I double
100 also conforms to
101 SVr4, 4.3BSD, C89.
102 .SH EXAMPLE
103 The program below produces results such as the following:
104 .sp
105 .nf
106 .in +4n
107 .RB "$" " ./a.out 2560"
108 frexp(2560, &e) = 0.625: 0.625 * 2^12 = 2560
109 .RB "$" " ./a.out \-4"
110 frexp(\-4, &e) = \-0.5: \-0.5 * 2^3 = \-4
111 .in
112 .fi
113 .SS Program source
114 \&
115 .nf
116 #include <math.h>
117 #include <float.h>
118 #include <stdio.h>
119 #include <stdlib.h>
120
121 int
122 main(int argc, char *argv[])
123 {
124     double x, r;
125     int exp;
126
127     x = strtod(argv[1], NULL);
128     r = frexp(x, &exp);
129
130     printf("frexp(%g, &e) = %g: %g * %d^%d = %g\\n",
131            x, r, r, FLT_RADIX, exp, x);
132     exit(EXIT_SUCCESS);
133 }
134 .fi
135 .SH "SEE ALSO"
136 .BR ldexp (3),
137 .BR modf (3)