ldexp() in C++


The function ldexp() is used to calculate the multiplication of a floating point value ‘a’ by the number 2 raised to the exponent power. It takes two arguments, first is a floating point number and second is an integer value.

Here is the mathematical expression of ldexp(),

ldexp() = a * 2^b

Here is the syntax of ldexp() in C++ language,

float ldexp(float variable1 , int variable2)

Here,

  • variable1  − Any name given to the variable which is representing the significand.

  • variable2  − Any name given to the variable which is representing the exponent.

Here is an example of ldexp() in C++ language,

Example

 Live Demo

#include <iostream>
#include <cmath>
using namespace std;

int main() {
   float x = 28.8;
   int y = 3;

   cout << "The value : " << ldexp(x, y);

   return 0;
}

Output

Here is the output

The value : 230.4

Updated on: 25-Jun-2020

65 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements