How to use ldexp() function to multiplies a floating point by the number 2 raised to the exp power in C

1 Answer

0 votes
#include <stdio.h>     
#include <math.h>     
 
int main(int argc, char **argv)
{   
	double x = 0.97;
	int exp = 5;
	double result = ldexp (x , exp);
	
	printf ("%.2f * 2^%d = %.2f\n", x, exp, result);
  
    return 0;
}
 
 
/*
run:
   
0.97 * 2^5 = 31.04

*/

 



answered Mar 22, 2016 by avibootz
...