AnsweredAssumed Answered

truncation,binary formats

Question asked by VRFuser on Apr 27, 1998
> 2.Is it possible to interpret the number 14.2567 in to binary format

This is from memory from when I was in school:

This is usually done by dealing with the integer and fractional parts
separately.  The integer is converted to binary using division.
Divide by 2 and the remainder is the binary digit for that place.
Repeat using the result of division and move up 1 binary digit till
you have 0 left.

11 / 2 = 5 R 1
5  / 2 = 2 R 1
2  / 2 = 1 R 0
1  / 2 = 0 R 1

11 (decimal) = 1011 (binary)

Using the same sort of logic, the fractional part of a decimal number
can be convert to binary by multipying.  The integer part is the
binary digit and gets tossed.  Repeat till 0 or desired precision.

0.65 * 2 = 1 +  0.3
0.3  * 2 = 0 +  0.6
0.6  * 2 = 1 +  0.2
0.2  * 2 = 0 +  0.4
0.4  * 2 = 0 +  0.8
0.8  * 2 = 1 +  0.6  (and it will now repeat)

0.65 (decimal) = 101001....(binary)

So,

11.65 (decimal) = 1011.101001.... (binary)

I hope this helps,

lBill

Outcomes