0
when i try to print double a=2343.34200000 it gives me only 2343.342 ??why this is happening can anybody tell me here
4 Answers
0
irl maths, there's no need to write zeroes after a decimal, so the program ignores it.
or it could be that double data-type could only store 8bytes, beyond that it can't
0
But there is a demand to print 2343.34200000 so what should i do đ
0
Davinder Kumar
Use %.8f
double t = 2343.34200000;
printf ("%.8f\n", t);
https://code.sololearn.com/c7Vzgaqi0PNM/?ref=app
0
Use I/O manipulator from <iomanip> header
#include <iostream>
#include <iomanip> // std::fixed, std::setprecision
int main()
{
double dbl_var {2343.34200000};
std::cout << std::fixed << std::setprecision( 8 ) << dbl_var << "\n";
// Reference:
// https://en.cppreference.com/w/cpp/io/manip/fixed
// https://en.cppreference.com/w/cpp/io/manip/setprecision
return 0;
}