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 versions <= 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       └────────────────────────────┴───────────────┴─────────┘

CONFORMING TO

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

EXAMPLES

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

SEE ALSO

90       ldexp(3), modf(3)
91

COLOPHON

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