C Standard Libraries C++

frexp()

Declaration

double frexp(double dX, int* ipExponent);

Description

This function transforms the value dX into a mantissa and exponent representation, where dX = Mantissa*2^(*ipExponent). The mantissa is the return value and *ipExponent is the exponent. The value dX is split up so that the mantissa that is returned is always greater than or equal to .5 and less than 1.0.

Overloads

float frexp(float, int*);
double frexp(double, int*);
long double frexp(long double, int*);

Related Functions

float frexpf(float, int*);
long double frexpl(long double, int*);

* Note: Since C does not allow function overloading, these other versions of this function exist.

Domain

(-∞, ∞)

Range

(-∞, ∞) X Integers

Periodicity

None

Symmetry

None

Asymptotes

None

 

Example

#include <iostream>
#include <cmath>

int main() {
    using namespace std;

    double dX = 1.2;
    int iExponent;
    cout << "x = " << dX << "  Mantissa = " << frexp(dX, &iExponent);
    cout << "  Exponent = " << iExponent << endl;

    dX = 6.0;
    cout << "x = " << dX << "  Mantissa = " << frexp(dX, &iExponent);
    cout << "  Exponent = " << iExponent << endl;

    return 0;
}

Output

frexp() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.