frexp function(Split into Fraction and Exponent) in C Language – example and detail

In the C Programming Language, the frexp characteristic splits a floating-point price into a fraction and an exponent. The fraction is lower back with the aid of the frexp function and the exponent is saved in the exp variable.


The syntax for the frexp feature in the C Language is:

double frexp(double value, int *exp);

Parameters or Arguments

value The floating-point cost to split into a fraction and an exponent. exp A pointer to an integer variable where the exponent will be stored.


The frexp characteristic returns the fractional part of value based totally on the equation: fraction x two exponent

The fraction ought to be increased than or equal to 0.5 and less than 1, or the fraction have to be equal to 0

Required Header

In the C Language, the required header for the frexp function is:

#include <math.h>

Applies To

In the C Language, the frexp characteristic can be used in the following versions:

ANSI/ISO 9899-1990

frexp Example

/* Example using frexp by */

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
    /* Define temporary variables */
    double value;
    int e;
    double f;

    /* Assign the value we will find the exp of */
    value = 1.5;

    /* Calculate the fraction and exponential of the value */
    f = frexp(value, &e);

    /* Display the result of the calculation */
    printf("The Fraction and Exponential of %f are %f and %d\n", value, f, e);

    return 0;

When compiled and run, this software will output:

The Fraction and Exponential of 1.500000 are 0.750000 and 1

Similar Functions

Other C functions that are similar to the frexp function:

ldexp function <math.h>

See Also

Other C features that are noteworthy when dealing with the frexp function:

modf function <math.h>