This blog is under construction

Monday, 30 April 2012

ldexp example in C

Header file:

     double ldexp(double x, int exp);

     Returns the value of x multiplied by 2 to the power of exp.

ldexp function C example:

  int main() {
        double x, res;
        int n;
        printf("Enter the value of x and n:");
        scanf("%lf%d", &x, &n);
        res = ldexp(x, n);
        printf("%lf * 2 ^ %d = %lf\n", x, n, res);
        return 0;

  jp@jp-VirtualBox:~/cpgms/math$ ./a.out
  Enter the value of x and n:2 4
  2.000000 * 2 ^ 4 = 32.000000

No comments:

Post a Comment