C/Math/Exp

Материал из C\C++ эксперт
Перейти к: навигация, поиск

Calculate exponential: how to use exp

#include <stdio.h>
#include <math.h>
int main ()
{
  double p, result;
 
  p = 5;
 
  result = exp (p);
 
  printf ("Exponential of %lf = %lf\n", p, result );
 
  return 0;
}


Get floating-point value from mantissa and exponent

#include <math.h>
#include <stdio.h>
int main(void)
{
  printf("%f", ldexp(1,2));
  return 0;
}


Get floating-point value from mantissa and exponent: how to use ldexp

#include <stdio.h>
#include <math.h>
int main () {
  double p, result;
  int n;
  p = 0.95;
  n = 4;
  result = ldexp (p, n);
  printf ("%f * 2^%d = %f\n", p, n, result);
  return 0;
}


Get mantissa and exponent of floating-point value: how to use frexp

#include <stdio.h>
#include <math.h>
int main ()
{
  double p, result;
  int n;
  p = 15.2;
  
  result = frexp (p , &n);
  
  printf ("%f * 2^%d = %f\n", result, n, p);
  
  return 0;
}