NAME |LIBRARY |SYNOPSIS |DESCRIPTION |RETURN VALUE |ERRORS |ATTRIBUTES |STANDARDS |HISTORY |EXAMPLES |SEE ALSO |COLOPHON | |
frexp(3) Library Functions Manualfrexp(3)frexp, frexpf, frexpl - convert floating-point number to fractional and integral components
Math library (libm,-lm)
#include <math.h>double frexp(doublex, int *e);float frexpf(floatx, int *e);long double frexpl(long doublex, int *e); Feature Test Macro Requirements for glibc (seefeature_test_macros(7)):frexpf(),frexpl(): _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L || /* Since glibc 2.19: */ _DEFAULT_SOURCE || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
These functions are used to split the numberx into a normalized fraction and an exponent which is stored ine.
These functions return the normalized fraction. If the argumentx is not zero, the normalized fraction isx times a power of two, and its absolute value is always in the range 1/2 (inclusive) to 1 (exclusive), that is, [0.5,1). Ifx is zero, then the normalized fraction is zero and zero is stored ine. Ifx is a NaN, a NaN is returned, and the value of*e is unspecified. Ifx is positive infinity (negative infinity), positive infinity (negative infinity) is returned, and the value of*e is unspecified.
No errors occur.
For an explanation of the terms used in this section, seeattributes(7). ┌──────────────────────────────────────┬───────────────┬─────────┐ │Interface│Attribute│Value│ ├──────────────────────────────────────┼───────────────┼─────────┤ │frexp(),frexpf(),frexpl() │ Thread safety │ MT-Safe │ └──────────────────────────────────────┴───────────────┴─────────┘
C11, POSIX.1-2008.
C99, POSIX.1-2001. The variant returningdouble also conforms to SVr4, 4.3BSD, C89.
The program below produces results such as the following: $./a.out 2560 frexp(2560, &e) = 0.625: 0.625 * 2^12 = 2560 $./a.out -4 frexp(-4, &e) = -0.5: -0.5 * 2^3 = -4Program source #include <float.h> #include <math.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { double x, r; int e; x = strtod(argv[1], NULL); r = frexp(x, &e); printf("frexp(%g, &e) = %g: %g * %d^%d = %g\n", x, r, r, 2, e, x); exit(EXIT_SUCCESS); }ldexp(3),modf(3)
This page is part of theman-pages (Linux kernel and C library user-space interface documentation) project. Information about the project can be found at ⟨https://www.kernel.org/doc/man-pages/⟩. If you have a bug report for this manual page, see ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩. This page was obtained from the tarball man-pages-6.15.tar.gz fetched from ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on 2025-08-11. If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up- to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.orgLinux man-pages 6.15 2025-07-19frexp(3)Pages that refer to this page:ldexp(3), modf(3)
HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |