How to convert 2.8147498e+14 (2^48) into a number ?

What does this symbol mean and how to convert 2.8147498e+14 to a number like 586456852156211 ,how to convert ?

1 Like

Number 2.8147498e+14; is written in scientific notation which is equal to 2.8147498*(10^14);

use this

#include <bits/stdc++.h>
#include <string>
double conversion(double counts)
{
  double d=0.0;
  std::ostringstream ss;
  ss.precision(1);
  ss << std::fixed << counts;
  std::string::size_type sz;     // alias of size_t

  d = std::stod (ss.str(),&sz);

  std::cout << ss.str() << " MeV";
  return d;
}
int main()
{
 double k=2.8147498e+14;
 float d;
 d=conversion(k);
 int exponent = (int)log10(fabs(d));
 double mantissa = d / pow(10, exponent);
 printf("%f X 10^%d\n", mantissa, exponent);
}

or you can use

#include <iostream>     // std::cout, std::fixed, std::scientific

int main () {
  double a = 3.1415926534;
  double b = 2006.0;
  double c = 1.0e-10;

  std::cout.precision(5);

  std::cout << "default:\n";
  std::cout << a << '\n' << b << '\n' << c << '\n';

  std::cout << '\n';

  std::cout << "fixed:\n" << std::fixed;
  std::cout << a << '\n' << b << '\n' << c << '\n';

  std::cout << '\n';

  std::cout << "scientific:\n" << std::scientific;
  std::cout << a << '\n' << b << '\n' << c << '\n';
  return 0;
}
1 Like
//