Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

for example 64's equivalent would be 0.5

share|cite|improve this question
$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
up vote 6 down vote accepted

Lets look at numbers 1 to 128 rather than 0 to 127 because 0 to 127 can get confusing and the same formula will work for 0 to 127. We want to scale, or divide, each number by something so that the largest number is 1 and the smallest number is something greater than zero. So lets look at our first idea.

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}.$

share|cite|improve this answer

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}$.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.