]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/frexp.3
isatty.3: Most non-tty files nowadays result in the error ENOTTY
[thirdparty/man-pages.git] / man3 / frexp.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
24.\"
25.\" References consulted:
26.\" Linux libc source code
27.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28.\" 386BSD man pages
29.\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
30.\" Modified 2002-07-27 by Walter Harms
31.\" (walter.harms@informatik.uni-oldenburg.de)
32.\"
4b8c67d9 33.TH FREXP 3 2017-09-15 "" "Linux Programmer's Manual"
fea681da
MK
34.SH NAME
35frexp, frexpf, frexpl \- convert floating-point number to fractional
36and integral components
37.SH SYNOPSIS
38.nf
39.B #include <math.h>
68e4db0a 40.PP
fea681da 41.BI "double frexp(double " x ", int *" exp );
fea681da 42.BI "float frexpf(float " x ", int *" exp );
fea681da
MK
43.BI "long double frexpl(long double " x ", int *" exp );
44.fi
68e4db0a 45.PP
20c58d70 46Link with \fI\-lm\fP.
68e4db0a 47.PP
6717c6ea
MK
48.in -4n
49Feature Test Macro Requirements for glibc (see
50.BR feature_test_macros (7)):
51.in
68e4db0a 52.PP
6717c6ea
MK
53.ad l
54.BR frexpf (),
55.BR frexpl ():
b90c43a8 56.RS 4
e9d91bcf
MK
57_ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
58 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
59 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
b90c43a8
MK
60.RE
61.ad
fea681da 62.SH DESCRIPTION
5600f73a 63These functions are used to split the number
022671eb
MK
64.I x
65into a
66normalized fraction and an exponent which is stored in
67.IR exp .
47297adb 68.SH RETURN VALUE
5600f73a 69These functions return the normalized fraction.
022671eb
MK
70If the argument
71.I x
72is not zero,
73the normalized fraction is
74.I x
75times a power of two,
a2af275c 76and its absolute value is always in the range 1/2 (inclusive) to
6717c6ea 771 (exclusive), that is, [0.5,1).
847e0d88 78.PP
022671eb
MK
79If
80.I x
81is zero, then the normalized fraction is
82zero and zero is stored in
83.IR exp .
847e0d88 84.PP
6717c6ea
MK
85If
86.I x
87is a NaN,
88a NaN is returned, and the value of
89.I *exp
90is unspecified.
847e0d88 91.PP
6717c6ea
MK
92If
93.I x
94is positive infinity (negative infinity),
95positive infinity (negative infinity) is returned, and the value of
96.I *exp
97is unspecified.
98.SH ERRORS
99No errors occur.
7e9ee9a4 100.SH ATTRIBUTES
a49c5865
MK
101For an explanation of the terms used in this section, see
102.BR attributes (7).
103.TS
104allbox;
105lbw27 lb lb
106l l l.
107Interface Attribute Value
108T{
7e9ee9a4
PH
109.BR frexp (),
110.BR frexpf (),
7e9ee9a4 111.BR frexpl ()
a49c5865
MK
112T} Thread safety MT-Safe
113.TE
47297adb 114.SH CONFORMING TO
9a74e018 115C99, POSIX.1-2001, POSIX.1-2008.
847e0d88 116.PP
6717c6ea
MK
117The variant returning
118.I double
119also conforms to
120SVr4, 4.3BSD, C89.
fea681da 121.SH EXAMPLE
a831ef97 122The program below produces results such as the following:
51f5698d 123.PP
a831ef97 124.in +4n
b8302363 125.EX
a831ef97
MK
126.RB "$" " ./a.out 2560"
127frexp(2560, &e) = 0.625: 0.625 * 2^12 = 2560
128.RB "$" " ./a.out \-4"
c3074d70 129frexp(\-4, &e) = \-0.5: \-0.5 * 2^3 = \-4
b8302363 130.EE
e646a1ba 131.in
a831ef97 132.SS Program source
d84d0300 133\&
e7d0bb47 134.EX
fea681da
MK
135#include <math.h>
136#include <float.h>
a2af275c
MK
137#include <stdio.h>
138#include <stdlib.h>
139
140int
141main(int argc, char *argv[])
142{
143 double x, r;
144 int exp;
145
146 x = strtod(argv[1], NULL);
147 r = frexp(x, &exp);
148
39ad75ab 149 printf("frexp(%g, &e) = %g: %g * %d^%d = %g\\n",
7295b7ed 150 x, r, r, FLT_RADIX, exp, x);
a2af275c 151 exit(EXIT_SUCCESS);
c54ed37e 152}
e7d0bb47 153.EE
47297adb 154.SH SEE ALSO
fea681da
MK
155.BR ldexp (3),
156.BR modf (3)