Lesson 3: Decimal 2 Binary
Number we want to transform uses base X: we would like to transform this number into new one, that uses Y base. In this case we will use method of continuous dividing and multiplying (dividing numbers left of comma (,) with Y and multiplying numbers on the right side of comma, by Y - rational numbers). This method is best understood looking at these examples where X equals 10 (decimal base, B=10), and Y eqauls 2 (binary base, B=2)Decimal System:
Base: 10
Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Binary System:
Base: 2
Digits: 0, 1
Example: 27 (decimal) = 11011 2 (binary)
Decimal 2 Binary
Example
Transform 29 (decimal) into binary number - reading upwards, result is 111012
29 : 2 = 14 , remaining 1 20 last (smallest) digit
14 : 2 = 7 , remaining 0 21
7 : 2 = 3 , remaining 1 22
3 : 2 = 1 , remaining 1 23
1 : 2 = 0 , remaining 1 24 first digit
- end of procedure
Example
Transform 0,8125 (decimal) into binary number – reading downwards, result is 0,11012
0,8125 * 2 = 1, 625 2-1 first digit after zero
0,625 * 2 = 1, 25 2-2
0,25 * 2 = 0, 5 2-3
0,5 * 2 = 1, 0 2-4 last digit
0,0 end of procedure
Example
Transform 0,3 (decimal) into binary number – result is 0,01001 1001 1001… 2shortly rounded = 0,010012
0,3 * 2 = 0, 6 2-1 first digit after zero
0,6 * 2 = 1, 2 2-2
--------
0,2 * 2 = 0, 4 2-3
0,4 * 2 = 0, 8 2-4
0,8 * 2 = 1, 6 2-5
0,6 * 2 = 1, 2 2-6
--------
…
…
procedure never ends
Example – Quick Method
Transform 53(decimal) into binary number using quick method
53 25 + 24 + 22 + 20 =
- 32 -> 25 1*25 + 1*24 + 0*23 + 1*22 + 0*21 + 1*20 =
-------- 110101 2
21
- 16 -> 24
--------
5
- 4 -> 22
--------
1
- 1 -> 20
--------
0 -> end of procedure
No comments:
Post a Comment