This blog is under construction

Monday 30 April 2012

frexp example in C

Header file:
    math.h

Synopsis:
     double frexp(double x, int *exp);

Description:
     It is used to split the number x into a fraction and exponent.  And this exponent is stored in exp.


frexp function C example:


  #include<stdio.h>
  #include<math.h>
  int main() {
        double x, res;
        int exp;
        printf("Enter the value for x:");
        scanf("%lf", &x);
        res = frexp(x, &exp);
        printf("Output: %lf\t exp:%d\n", res, exp);
        printf("res(%lf) * 2 ^ exp(%d) = x(%lf)\n", res, exp, res*pow(2,exp));
        return 0;
  }



  Output: 
  jp@jp-VirtualBox:~/cpgms/math$ ./a.out
  Enter the value for x:64
  Output: 0.500000     exp:7
  res(0.500000) * 2 ^ exp(7) = x(64.000000)


1 comment:

  1. Do you need Finance? Are you looking for Finance? Are you looking for finance to enlarge your business? We help individuals and companies to obtain finance for business expanding and to setup a new business ranging any amount. Get finance at affordable interest rate of 3%, Do you need this finance for business and to clear your bills? Then send us an email now for more information contact us now via (financialserviceoffer876@gmail.com) whats-App +918929509036 Dr James Eric Finance Pvt Ltd Thanks

    ReplyDelete