Number Systems TA: Mamun References: Lecture notes of Introduction to Information Technologies (ITEC 1011) by Dr Scott MacKenzie
Common Number Systems System Base Symbols Decimal 10 0, 1, 9 Binary 2 0, 1 Octal 8 0, 1, 7 16 0, 1, 9, A, B, F
Counting Decimal Binary Octal 0 0 0 0 1 1 1 1 2 10 2 2 3 11 3 3 4 100 4 4 5 101 5 5 6 110 6 6 7 111 7 7 Decimal Binary Octal 8 1000 10 8 9 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 15 D 14 1110 16 E 15 1111 17 F
Counting Decimal Binary Octal 16 10000 20 10 17 10001 21 11 18 10010 22 12 19 10011 23 13 20 10100 24 14 21 10101 25 15 22 10110 26 16 23 10111 27 17 24 10 =? 24 10 = 11000 2 = 30 8 = 18 16
Decimal to Decimal Decimal Octal Binary
125 10 =>? 10 - Multiply each bit by 10 n, where n is the weight of the bit - The weight is the position of the bit, starting from 0 on the right Weight 125 10 => 5 x 10 0 = 5 2 x 10 1 = 20 1 x 10 2 = 100 125 Add the results Base
Binary to Decimal Decimal Octal Binary
Binary to Decimal Technique 1. Multiply each bit by 2 n, where n is the weight of the bit 2. The weight is the position of the bit, starting from 0 on the right 3. Add the results
101011 2 =>? 10 101011 2 => 1 x 2 0 = 1 1 x 2 1 = 2 0 x 2 2 = 0 1 x 2 3 = 8 0 x 2 4 = 0 1 x 2 5 = 32 43 10
Octal to Decimal Decimal Octal Binary
Octal to Decimal Technique 1. Multiply each bit by 8 n, where n is the weight of the bit 2. The weight is the position of the bit, starting from 0 on the right 3. Add the results
724 8 =>? 10 724 8 => 4 x 8 0 = 4 2 x 8 1 = 16 7 x 8 2 = 448 468 10
to Decimal Decimal Octal Binary
to Decimal Technique 1. Multiply each bit by 16 n, where n is the weight of the bit 2. The weight is the position of the bit, starting from 0 on the right 3. Add the results
ABC 16 =>? 10 Decimal Binary Octal 8 1000 10 8 9 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 15 D 14 1110 16 E 15 1111 17 F ABC 16 => C x 16 0 = 12 x 1 = 12 B x 16 1 = 11 x 16 = 176 A x 16 2 = 10 x 256 = 2560 2748 10
Decimal to Binary Decimal Octal Binary
Decimal to Binary Technique 1. Divide by 2, keep track of the remainder 2. First remainder is LSB, least-significant bit 3. Last remainder is MSB, most-significant bit
125 10 =? 2 2 125 2 62 1 2 31 0 2 15 1 2 7 1 2 3 1 2 1 1 0 1 125 10 = 1111101 2
Decimal to Octal Decimal Octal Binary
Decimal to Octal Technique 1. Divide by 8 2. Keep track of the remainder
1234 10 =? 8 8 1234 8 154 2 8 19 2 8 2 3 0 2 1234 10 = 2322 8
Decimal to Decimal Octal Binary
Decimal to Technique 1. Divide by 16 2. Keep track of the remainder
1234 10 =? 16 16 1234 16 77 2 16 4 13 = D 0 4 1234 10 = 4D2 16
Any base to any base Base-x Base-y
Any base to any base Technique 1. Use Decimal as an intermediary Base-x Base-y Decimal
432 4 =? 7 432 4 =>? 10 =>? 7 432 4 => 2 x 4 0 7 78 = 2 3 x 4 1 7 11 1 = 12 4 x 4 2 = 64 7 1 4 78 0 1 10 78 10 = 141 7 432 4 = 141 7
Conversion Among Bases Division algorithm Base-y Decimal Octal Base-x Binary
Octal to Binary Decimal Octal Binary
Octal to Binary Technique Convert each octal digit to a 3-bit equivalent binary representation
705 8 =? 2 Decimal Binary Octal 0 0 0 0 1 1 1 1 2 10 2 2 3 11 3 3 4 100 4 4 5 101 5 5 6 110 6 6 7 111 7 7 7 0 5 111 000 101 705 8 = 111000101 2
to Binary Decimal Octal Binary
to Binary Technique Convert each hexadecimal digit to a 4-bit equivalent binary representation
10AF 16 =? 2 Decimal Binary Octal 8 1000 10 8 9 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 15 D 14 1110 16 E 15 1111 17 F 1 0 A F 0001 0000 1010 1111 10AF 16 = 0001000010101111 2
Binary to Octal Technique 1. Group bits in threes, starting on right 2. Convert to octal digits
1011010111 2 =? 8 Decimal Binary Octal 0 0 0 0 1 1 1 1 2 10 2 2 3 11 3 3 4 100 4 4 5 101 5 5 6 110 6 6 7 111 7 7 1 011 010 111 1 3 2 7 1011010111 2 = 1327 8
Binary to Decimal Octal Binary
Binary to Technique 1. Group bits in fours, starting on right 2. Convert to hexadecimal digits
1010111011 2 =? 16 Decimal Binary Octal 8 1000 10 8 9 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 15 D 14 1110 16 E 15 1111 17 F 10 1011 1011 2 B B 1010111011 2 = 2BB 16
Octal to Decimal Octal Binary
Octal to Technique Use binary as an intermediary
1076 8 =? 16 1 0 7 6 Decimal Binary Octal 8 1000 10 8 9 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 15 D 14 1110 16 E 15 1111 17 F 001 000 111 110 2 3 E 1076 8 = 23E 16
to Octal Decimal Octal Binary
to Octal Technique Use binary as an intermediary
1F0C 16 =? 8 Decimal Binary Octal 8 1000 10 8 9 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 15 D 14 1110 16 E 15 1111 17 F 1 F 0 C 0001 1111 0000 1100 1 7 4 1 4 1F0C 16 = 17414 8
Conversion Among Bases Short-cut Octal Binary
Questions? Next tutorial ASCII UTF-8 Floating-point arithmetic