std::numeric_limits<T>
in limits
:
Provides information about the properties of arithmetic types (either integral or floating-point) in the specific platform for which the library compiles.
std::setprecision
in iomanip
:
Sets the decimal precision to be used to format floating-point values on output operations.
So, you can use:
#include <iostream>
#include <iomanip> // setprecision()
#include <limits>
using namespace std;
int main()
{
unsigned int x = 293125555;
double y = (double)x/1000.0;
cout << setprecision(numeric_limits<double>::digits10 + 1)
<< y
<< endl;
return 0;
}
and get the expected result:
293125.555