2 ms·
> 9999999999999999.0 into "double" gives https://float.exposed/0x4341c37937e08000 https://float.exposed/0x4341c37937e08000 Nice that it reformats the input to
by DougBTX 8y ago
> 9999999999999999.0 into "double" gives https://float.exposed/0x4341c37937e08000 https://float.exposed/0x4341c37937e08000
Nice that it reformats the input to "10000000000000000.0", gets the point across that a 64 bit double float just doesn't have enough bits to exactly represent 9999999999999999.0, but that it does happen to be able to represent 9999999999999998.0.
- loeg 8y agoAn easy rule of thumb is each 3 decimal digits takes 10 bits to represent. 9999999999999999 is 16 (= 15 + 1) decimal digits. And 3 bits can only represent 0-7. So you need more than 3 bits for that final decimal digit. So, 50 + 4 bits. IEEE 754 64-bit floats have 53 significant bits ("mantissa").