When casting from a large uint64_t value to a double. The results are not as expected. Why is this, and is there a way to solve it. I'm using gcc 8.3.0
int main
{
uint64_t var64 = 844421103279395000;
printf("var64 = %llu\n", var64 );
double varDouble = (double)var64;
printf("varDouble = %lf\n", varDouble );
return 0;
}
The output is as follows :
var64 = 844421103279395000
varDouble = 844421103279394940.000000