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           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
22               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
23               || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
24

DESCRIPTION

26       These functions are used to split the number x into a normalized  frac‐
27       tion and an exponent which is stored in exp.
28

RETURN VALUE

30       These  functions  return the normalized fraction.  If the argument x is
31       not zero, the normalized fraction is x times a power of  two,  and  its
32       absolute value is always in the range 1/2 (inclusive) to 1 (exclusive),
33       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

ATTRIBUTES

47       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
48       tributes(7).
49
50       ┌────────────────────────────────────────────┬───────────────┬─────────┐
51Interface                                   Attribute     Value   
52       ├────────────────────────────────────────────┼───────────────┼─────────┤
53frexp(), frexpf(), frexpl()                 │ Thread safety │ MT-Safe │
54       └────────────────────────────────────────────┴───────────────┴─────────┘
55

CONFORMING TO

57       C99, POSIX.1-2001, POSIX.1-2008.
58
59       The variant returning double also conforms to SVr4, 4.3BSD, C89.
60

EXAMPLES

62       The program below produces results such as the following:
63
64           $ ./a.out 2560
65           frexp(2560, &e) = 0.625: 0.625 * 2^12 = 2560
66           $ ./a.out -4
67           frexp(-4, &e) = -0.5: -0.5 * 2^3 = -4
68
69   Program source
70
71       #include <math.h>
72       #include <float.h>
73       #include <stdio.h>
74       #include <stdlib.h>
75
76       int
77       main(int argc, char *argv[])
78       {
79           double x, r;
80           int exp;
81
82           x = strtod(argv[1], NULL);
83           r = frexp(x, &exp);
84
85           printf("frexp(%g, &e) = %g: %g * %d^%d = %g\n",
86                  x, r, r, FLT_RADIX, exp, x);
87           exit(EXIT_SUCCESS);
88       }
89

SEE ALSO

91       ldexp(3), modf(3)
92

COLOPHON

94       This  page  is  part of release 5.12 of the Linux man-pages project.  A
95       description of the project, information about reporting bugs,  and  the
96       latest     version     of     this    page,    can    be    found    at
97       https://www.kernel.org/doc/man-pages/.
98
99
100
101                                  2021-03-22                          FREXP(3)
Impressum