double a = 2451550;
double b = .407864;
double c= a*b;
cout<<c;
I was expecting the results to be "999898.9892" but getting "999899". I need the actual unrounded result.Please suggest.
By default, iostreams output 6 digits of precision. If you want more, you have to ask for it:
std::cout.precision(15);
It can also be done using Manipulator setprecision like below.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double a = 2451550;
double b = .407864;
double c= a*b;
cout<<setprecision(15)<<c;
}
Also, Usage of manipulator will make the code compact.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With