Consider 3 randomly chosen floating point values and their base conversions:

Floating point        Base-16    Base-15
0.5898704528808594  = 0.9701c    0.8cac2d1d9bd5e9
0.21180343627929688 = 0.3638c    0.329c837b2b291b
0.8631706237792969  = 0.dcf8c    0.ce3302d46d553

The same issue occurs with Base-24, and 32: The representation of the float is very compact.

These were found by searching random IEE754 binary64 double numbers, isolating those with the criteria of less than 6 hex digits. To reduce the search, I forced the lower 33 bits of the mantissa to 0 prior to converting to double. I'm not entirely sure why, but this only seems to happen if the lower 33 bits of the mantissa are zero. I ended up with a list of only 1048225 that met the criteria after 2.2 billion numbers, which is strikingly close to 2^20.

In fraction form, these 3 numbers happen to have a denominator of 262144. Others I've found have denominators of 1048576, 65536, 262144, etc. - the denominator always seems to be a power of 2 when this happens.

Is there an explanation for this?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.