# integer to float

How can represent any number from 0 to 127 as something between 0 and 1 ?

for example 64's equivalent would be 0.5

-
$0.1 \cdot (127 / 10) = 1.27 > 1$. – cardinal Apr 17 '11 at 2:18
Just divide by 128. This is equivalent to using a seven-bit binary representation and placing the decimal point out front. So, for example, 64 in binary is 1000000 and $0.1000000$ in binary is 0.5 (decimal). – cardinal Apr 17 '11 at 2:20

Call this number we want to divide by $x.$ Because we want our largest number, 128, to be equivalent to 1, we should get something like this: $\frac{128}{x}=1.$ Bring the $x$ to the other side and we will get $x=128.$
So every number can be converted to a ''float'' by $\frac{number}{128}.$
You could separate the segment between $0$ and $1$ into $128$ pieces, and from there on map $x$ (where $x\in \begin{Bmatrix} 0, & 1, & \dots, & 127 \end{Bmatrix}$) to $x \times \frac{1}{127}$.