1FREXP(3)                   Linux Programmer's Manual                  FREXP(3)
2
3
4

NAME

6       frexp, frexpf, frexpl - convert floating-point number to fractional and
7       integral components
8

SYNOPSIS

10       #include <math.h>
11
12       double frexp(double x, int *exp);
13       float frexpf(float x, int *exp);
14       long double frexpl(long double x, int *exp);
15
16       Link with -lm.
17
18   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20       frexpf(), frexpl():
21           _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 ||
22           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L;
23           or cc -std=c99
24

DESCRIPTION

26       The  frexp()  function  is used to split the number x into a normalized
27       fraction and an exponent which is stored in exp.
28

RETURN VALUE

30       The frexp() function returns the normalized fraction.  If the  argument
31       x  is  not zero, the normalized fraction is x times a power of two, and
32       its absolute value is always in the range 1/2 (inclusive) to 1  (exclu‐
33       sive), that is, [0.5,1).
34
35       If  x  is zero, then the normalized fraction is zero and zero is stored
36       in exp.
37
38       If x is a NaN, a NaN is returned, and the value of *exp is unspecified.
39
40       If x is positive infinity (negative infinity), positive infinity (nega‐
41       tive infinity) is returned, and the value of *exp is unspecified.
42

ERRORS

44       No errors occur.
45

CONFORMING TO

47       C99, POSIX.1-2001.  The variant returning double also conforms to SVr4,
48       4.3BSD, C89.
49

EXAMPLE

51       The program below produces results such as the following:
52
53           $ ./a.out 2560
54           frexp(2560, &e) = 0.625: 0.625 * 2^12 = 2560
55           $ ./a.out -4
56           frexp(-4, &e) = -0.5: -0.5 * 2^3 = -4
57
58   Program source
59
60       #include <math.h>
61       #include <float.h>
62       #include <stdio.h>
63       #include <stdlib.h>
64
65       int
66       main(int argc, char *argv[])
67       {
68           double x, r;
69           int exp;
70
71           x = strtod(argv[1], NULL);
72           r = frexp(x, &exp);
73
74           printf("frexp(%g, &e) = %g: %g * %d^%d = %g\n",
75                  x, r, r, FLT_RADIX, exp, x);
76           exit(EXIT_SUCCESS);
77       }
78

SEE ALSO

80       ldexp(3), modf(3)
81

COLOPHON

83       This page is part of release 3.53 of the Linux  man-pages  project.   A
84       description  of  the project, and information about reporting bugs, can
85       be found at http://www.kernel.org/doc/man-pages/.
86
87
88
89                                  2010-09-20                          FREXP(3)
Impressum