Lecture-3
Number Systems
CONVERSION BETWEEN NUMBER BASES
The possibilities:
Decimal Binary
Octal Hexadecimal
Number Systems 2
CONVERSION FROM BINARY TO OCTAL
Decimal Binary
Octal Hexadecimal
Number Systems 3
CONVERSION FROM BINARY TO OCTAL
Technique:
1. Group bits in threes, starting on right for integer part and from left for fractional part.
2. Ignore leading zeros and add zeros after decimal if necessary, to form group of three
bits.
3. Convert to octal digits
Example: (1011010111)2 = (N)8
(1011010111)2 = (1327)8
Number Systems 4
CONVERSION FROM BINARY TO OCTAL
Example: (1010111000.0101)2 = (N)8
1 010 111 000 . 010 100
1 2 7 0 . 2 4
(1010111000.0101)2 = (1270.24)8
Number Systems 5
CONVERSION FROM BINARY TO HEXADECIMAL
Decimal Binary
Octal Hexadecimal
Number Systems 6
CONVERSION FROM BINARY TO HEXADECIMAL
Technique:
1. Group bits in fours, starting on right for integer part and from left for fractional part.
2. Ignore leading zeros and add zeros after decimal if necessary, to form group of four bits.
3. Convert to hexadecimal digits
Example: (1010111011)2 = (N)16
(1010111011)2 = (2BB)16
Number Systems 7
CONVERSION FROM BINARY TO HEXADECIMAL
Example: (1010111000.0101)2 = (N)16
0010 1011 1000 . 0101
2 B 8 . 5
(1010111000.0101)2 = (2B8.5)16
Number Systems 8
CONVERSION FROM OCTAL TO BINARY
Decimal Binary
Octal Hexadecimal
Number Systems 9
CONVERSION FROM OCTAL TO BINARY
Technique:
1. Convert each octal digit to a 3-bit equivalent binary representation
Example: (705)8 = (N)2
(705)8 = (111000101)2
Number Systems 10
CONVERSION FROM OCTAL TO BINARY
Example: (1472.16)8 = (N)2
1 4 7 2 . 1 6
1 100 111 010 . 001 110
(1472.16)8 = (1100111010.00111)2
Number Systems 11
CONVERSION FROM OCTAL TO HEXADECIMAL
Decimal Binary
Octal Hexadecimal
Number Systems 12
CONVERSION FROM OCTAL TO HEXADECIMAL
Technique:
1. Use binary as an intermediary
Example: (1472.16)8 = (N)16
1 4 7 2 . 1 6
1 100 111 010 . 001 110 (1472.16)8 = (33A.38)16
001 100 111 010 . 001 11000
3 3 A . 3 8
Number Systems 13
CONVERSION FROM HEXADECIMAL TO BINARY
Decimal Binary
Octal Hexadecimal
Number Systems 14
CONVERSION FROM HEXADECIMAL TO BINARY
Technique:
1. Convert each hexadecimal digit to a 4-bit equivalent binary representation
Example: (10AF)16 = (N)2
(10AF)16 = (1000010101111)2
Number Systems 15
CONVERSION FROM HEXADECIMAL TO BINARY
Example: (A5BF.0C)16 = (N)2
A 5 B F . 0 C
1010 0101 1011 1111 . 0000 1100
(A5BF.0C)16 = (1010010110111111.000011)2
Number Systems 16
CONVERSION FROM HEXADECIMAL TO OCTAL
Decimal Binary
Octal Hexadecimal
Number Systems 17
CONVERSION FROM HEXADECIMAL TO OCTAL
Technique:
1. Use binary as an intermediary
Example: (A5BF.0C)16 = (N)8
A 5 B F . 0 C
1010 0101 1011 1111 . 0000 1100 (A5BF.0C)16 = (122677.03)8
001010 0101 1011 1111 . 0000 1100
1 2 2 6 7 7 . 0 3
Number Systems 18
ASSIGNMENT QUESTION
Fill the table:
Number Systems 19
Binary Arithmetic
Number Systems 20
BINARY ADDITION
Two 1-bit values:
Number Systems 21
BINARY ADDITION
Two n-bit values:
Add individual bits
Propagate carries
Example:
1 1 1 1 1 1 carries
1
1 1 1 0 1 6 1
+ 1 0 1 1 1 + 2 3
--------------------- ----------
1 0 1 0 1 0 0 8 4
Number Systems 22
BINARY ADDITION
Two n-bit values:
Add individual bits
Propagate carries
Example:
Number Systems 23
BINARY SUBTRACTION
Two 1-bit values:
With Borrow 1
Number Systems 24
BINARY SUBTRACTION
Two n-bit values:
Subtract individual bits with borrow if necessary
Example:
10- decimal value 2
10
0 0 10 Borrows
1 1 1 1 0 1 6 1
- 1 0 1 1 1 - 2 3
--------------------- ----------
1 0 0 1 1 0 3 8
EXAMPLE: 1. 1101-1011
2. 11001-01111
Number Systems 25
BINARY MULTIPLICATION
Two 1-bit values:
Number Systems 26
BINARY MULTIPLICATION
Example:
1 0 1 1 1 2 3
X 1 0 1 0 X 1 0
----------------------- ----------
0 0 0 0 0 2 3 0
1 0 1 1 1
0 0 0 0 0
1 0 1 1 1
-----------------------
1 1 1 0 0 1 1 0
Number Systems 27
ASSIGNMENT QUESTIONS
1. Add: (1000111)2 + (1110)2
2. Subtract: (1110000)2 – (1111)2
3. Multiply: (101)2 x (10101)2
Number Systems 28
Number Systems 29