I want to initialise a double with a hex constant.
double dbl = 0xFEDCBA9876543212;
printf("dbl: %llX\n", (uint64_t)dbl);
I would expect to see as the output:
dbl: FEDCBA9876543212
But I am getting:
dbl: FEDCBA9876543000
Why is this and why are the last 3 bytes being dropped off?
You are using a 64-bit value to initialize a double, which only holds 53 significant bits. There's one bit of rounding, and the remaining bits are just lost.
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