#include<iostream>
using namespace std;
int main()
{
unsigned int x = 293125555;
double y = (double)x/1000.0;
cout << y << endl;
return 0;
}
I expect the output to be 293125.555 but i get 293126 instead. Is this because of the way double are stored in memory?
std::numeric_limits<T>inlimits:std::setprecisioniniomanip:So, you can use:
and get the expected result: