Digital Logic Design (CEN-120)
(3+1)
SENIOR LECTURER Engr. Syed Rizwan Ali, MS(CAAD) UK, PDG(CS) UK, PGD (PM) IR, BS (BCE) PK HEC Certified – Master Trainer (MT-FPDP) Computer Sciences Department Bahria University (Karachi Campus)
DIFFERENT NUMBER SYSTEMS Lecture No 02.2 Floyd, Digital Fundamentals, 10th edBy Engr. Syed Rizwan © 2009 Pearson Ali Education, Upper Saddle River, NJ 07458. All Rights Reserved
Lecture Content In this Class, we will be learning… Different number systems Why use different ones? Binary / Octal / Hexadecimal Conversions Negative number representation Binary Arithmetic Overflow / Underflow Addition / Subtraction
Different Number Systems
Different Number System
The system used to count discrete units is called number system. There are four systems of arithmetic which are often used in digital electronics. Decimal Number System Binary Number System Octal Number System Hexa Decimal System
Why Use Different One?
Computers work only on two states
On Off
Basic memory elements hold only two states
Zero / One
Thus a number system with two elements {0,1} A binary digit – bit !
Common Number System System
Base Symbols
Used by humans?
Decimal
10
0, 1, … 9
Yes
Binary
2
0, 1
No
Octal
8
0, 1, … 7
No
Hexadecimal
16
0, 1, … 9, A, B, … F
No
Quantities/Counting (1 of 3) Decimal 0 1 2 3 4 5 6 7
Binary 0 1 10 11 100 101 110 111
Octal 0 1 2 3 4 5 6 7
Hexa-Decimal 0 1 2 3 4 5 6 7
Quantities/Counting (2 of 3) Decimal 8 9 10 11 12 13 14 15
Binary 1000 1001 1010 1011 1100 1101 1110 1111
Octal 10 11 12 13 14 15 16 17
Hexa-Decimal 8 9 A B C D E F
Quantities/Counting (3 of 3) Decimal 16 17 18 19 20 21 22 23
Binary Octal 10000 20 10001 21 10010 22 10011 23 10100 24 10101 25 10110 26 10111 27
Hexa-Decimal 10 11 12 13 14 15 16 17
Conversions
Conversion Among Bases
The possibilities: Decimal
Octal
Binary
Hexadecimal
Binary
Decimal
1101 = 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20 =1x8+1x4+0x2+1x1 =8+4+0+1 (1101)2 = (13)10
1, 2, 4, 8, 16, 32, 64, 128, 256, 512, ….
Decimal
Binary
2
13
1
LSB
2 2 2
6 3 1 0
0 1 1
MSB
(13)10 = (1101)2
Octal
Decimal
(137) 8 = (?) 10 = 1 x 82 + 3 x 8 1 + 7 x 80 = 1 x 64 + 3 x 8 + 7 x 1 = 64 + 24 + 7 (137)8 = (95)10
Digits used in Octal number system – 0 to 7
Decimal
8 95 8 11 1-
Octal
7
3
8 95
7
8 11 1-
3 1
1
(95)10 = (137)8
LSB
MSB
Hexa
Decimal
BAD = 11 x 162 + 10 x 161 + 13 x 160 = 11 x 256 + 10 x 16 + 13 x 1 = 2816 + 160 + 13 (BAD)16 = (2989)10
A = 10, B = 11, C = 12, D = 13, E = 14, F = 15
Decimal
Hexa
16 2989
13
16 186 11 -
10 11
LSB
MSB
(2989)10 = (BAD)16
Why octal or hex?
Ease of use and conversion Three bits make one octal digit 111 010 110 101 7 2 6 5 => (7265)8 in octal
Four bits make one hexadecimal digit 4 bits = nibble 1110 1011 0101 E B 5 => (EB5)16 in hex
Fractions
Natural to Decimal 3.14 =>
4 x 10-2 = 0.04 1 x 10-1 = 0.1 3 x 100 = 3 3.14
Fractions
Binary to decimal 10.1011 =>
1 x 2-4 = 0.0625 1 x 2-3 = 0 x 2-2 = 1 x 2-1 = 0 x 20 = 1 x 21 =
0.125 0.0 0.5 0.0 2.0 2.6875
Fractions
Decimal to binary 3.14579
11.001001...
.14579 x 2 0.29158 x 2 0.58316 x 2 1.16632 x 2 0.33264 x 2 0.66528 x 2 1.33056 etc.
Any Questions
??
???