ldexp()

Declaration

double ldexp(double dMantissa, int iExponent);

Description:

This function transforms the value of a mantissa and an exponent into a real number that is returned as dMantissa*2^iExponent.

Overloads

float ldexp(float, int);
double ldexp(double, int);
long double ldexp(long double, int);

Related Functions

float ldexpf(float, int);
long double ldexpl(long double, int);

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

Domain

(-∞, ∞) x Integers

Range

(-∞, ∞)

Periodicity

None

Symmetry

None

Asymptotes

None

 

Example

#include <iostream>
#include <cmath>

int main() {
    using namespace std;

    double dMantissa = 1.2;
    int iExponent = 4;
    cout << "Mantissa = " << dMantissa << "  Exponent = " << iExponent <<
        "  ldexp(Mantissa, Exponent) = " << ldexp(dMantissa, iExponent) << endl;

    dMantissa = .2;
    iExponent = 2;
    cout << "Mantissa = " << dMantissa << "  Exponent = " << iExponent <<
        "  ldexp(Mantissa, Exponent) = " << ldexp(dMantissa, iExponent) << endl;

    return 0;
}

Output:

ldexp() Output