x = c * (2**p) # the value you want to express
c # the coefficient
p = -n # the smallest power of two that goes into x;
# negative, since it's a binary fraction
x = c*(2**p) = c*(2**-n) = ...
[ 1 ] [ 1 ] [ 5**n ] [ 5**n ]
= ... = c*[------] = c*[------]*[------] = c*[-------] = ...
[ 2**n ] [ 2**n ] [ 5**n ] [ 10**n ]
= ... = c * (5**n) * (10**-n) = c * (5**n) ** (10**p)
k = c * (5**n) # k integer, so exactly representable in decimal
x = k * (10**-n) # since n is finite and k is an integer,
# x is exactly representable in decimal
####
x c*(2**-n) binary decimal d log10(x)
1/2 1*(2**-1) 0b0.1 0.5 1 -0.301029996
1/4 1*(2**-2) 0b0.01 0.25 1 -0.602059991
3/4 3*(2**-2) 0b0.11 0.75 1 -0.124938737
1/8 1*(2**-3) 0b0.001 0.125 1 -0.903089987
7/8 7*(2**-3) 0b0.111 0.875 1 -0.057991947
1/16 1*(2**-4) 0b0.0001 0.0625 2 -1.204119983
15/16 15*(2**-4) 0b0.1111 0.9375 1 -0.028028724
1/32 1*(2**-5) 0b0.00001 0.03125 2 -1.505149978
1/64 1*(2**-6) 0b0.000001 0.015625 2 -1.806179974
1/128 1*(2**-7) 0b0.0000001 0.0078125 3 -2.107209970
3/128 3*(2**-7) 0b0.0000011 0.0234375 2 -1.630088715
5/128 5*(2**-7) 0b0.0000101 0.0390625 2 -1.408239965
9/128 9*(2**-7) 0b0.0001001 0.0703125 2 -1.152967460
13/128 13*(2**-7) 0b0.0001101 0.1015625 1 -0.993266617
##
##
1.0000 0000 0000 000f ffff ffff ffff ffff ffff ffff ffff ffff ffff
^1 16^ 52^
^ points to the nth digit after decimal point