You are on page 1of 19

CSE 204

Digital Logic Design

Lecture 03
Dr. Tarem Ahmed
Number Ranges: Decimal System
• Range of numbers that may be
represented using n digits?

• Highest number value that may be


represented using n digits?

• Total number of integers that may be


represented using n digits?
Number Ranges: Binary
• Range of numbers that may be
represented using n bits?

• Highest number value that may be


represented using n bits?

• Total number of integers that may be


represented using n bits?
Number Ranges: Arbitrary Base
• Range of numbers that may be
represented using n, base-r units?

• Highest number value that may be


represented using n, base-r units?

• Total number of integers that may be


represented using n, base-r units?
Exercise:
1) Try converting
(10110001101011.111100000110)2
To:
a) octal b) hexadecimal

2) Try converting to binary:


a) (673.124)8
b) (306.D)16
Answers:
(1) a) (26153.7406)8
(2) b) (2C6B.F06)16

(2) a) (110 111 011 . 001 010 100)2

(2) b) (0011 0000 0110 . 1101)2


Binary Operations: Addition
For 2 bits For 3 bits
• 0 + 0 = 0 0 ( 0 with a 0 • 0+0+0 = 0 0 (0 WITH 0
carry ) CARRY)
• 0 + 1 = 0 1 ( 1 with a 0 • 0+0+1 = 0 1 (1 WITH 0
carry ) CARRY)
• 1 + 0 = 0 1 ( 1 with a 0 • 0+1+1 = 1 0 (0 WITH 1
carry ) CARRY)
• 1 + 1 = 1 0 ( 0 with a 1
• 1+1+1 = 1 1 (1 WITH 1
carry )
CARRY)
Adding Binary Numbers

0 1 1 1 0 0 0
28  00011100
+ 43  + 00101011
71 01000111

8
Adding Binary Numbers
• From right to left, we add each pair of digits
• We write the sum, and add the carry to the
next column on the left

1 9 0 1
8 1
+ 2 6 6 + 0 0
4 2 1 0 0
4 1
0 1 1 0 1 1
Sum Sum
Carry Carry
Exercise:
Add (101101) 2 with (100111) 2 :
Solution
Ans: (1010100) 2

Working:
Augend: 101101
Addend: +100111
Sum: 1010100
Addition in base r
• Example:
( 34)5+ (41)5+ (24)5 4+1+4= 9
9%5=4
1+3+4+2= 10 9/5=1 (carry)
10%5=0 21
10/5=2 (carry) (34)5
(41)5
+ (24)5
________________
(2 0 4)5
Exercises:
• Try:
(FF)16+(F1)16
(66)7 + (55)7
Binary Coded Decimal (BCD)
 Decimal numbers are more natural to humans.
Binary numbers are natural to computers. Quite
expensive to convert between the two.
 If little calculation is involved, we can use some
coding schemes for decimal numbers.
 One such scheme is BCD, also known as the
8421 code.
 Represent each decimal digit as a 4-bit binary
code.
BCD
Decimal digit 0 1 2 3 4
BCD 0000 0001 0010 0011 0100
Decimal digit 5 6 7 8 9
BCD 0101 0110 0111 1000 1001

 Some codes are unused, eg: (1010)BCD, (1011) BCD,


…, (1111) BCD. These codes are considered as errors.
 Easy to convert, but arithmetic operations are
more complicated.
 Suitable for interfaces such as keypad inputs and
digital readouts.
BCD
Decimal digit 0 1 2 3 4
BCD 0000 0001 0010 0011 0100
Decimal digit 5 6 7 8 9
BCD 0101 0110 0111 1000 1001

 Examples:
(234)10 = (0010 0011 0100)BCD
(7093)10 = (0111 0000 1001 0011)BCD
(1000 0110)BCD = (86)10
(1001 0100 0111 0010)BCD = (9472)10
Note: BCD is NOT equivalent to Binary
Example: (234)10 = (11101010)2
ASCII
• American Standard Code for Information
Interchange
• Table 1-4
• 7 bit representation of English letters,
Arabic numbers, common Special
characters and Control characters
Unicode
• 16-bit
• Represents letters in 139 languages,
emoticons…
Notes
• Reading
– Mano and Kime, Ch 1-3~5

• HW1
– Mano and Kime, Ch 1
– Soln will be posted today

• Quiz1
– Mano and Kime, Ch 1
– Next class

You might also like