













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
These lecture slides are very helpful for the student of discrete mathematics. The major points in these exam paper are: Binary Numbers, Number Systems, Gray Code, Negative Numbers, Residual Numbers, Coverage of Integer, Enumeration of Binary Numbers, Range of Representation, Equality of Addition, Variation of Binary Code
Typology: Slides
1 / 21
This page cannot be seen from the preview
Don't miss anything!














Lecture 2: Number Systems: Binary Numbers and Gray Code 1
2 where b i in {0,1} for 0<= i < n
n- 1
1 +b 0
0
When we enumerate binary numbers (b 3 b 2 b 1 b 0
2 from 0 to 15, the sequence of b 3 should be
Given two binary numbers A & B, we derive binary number S so that the value of S is equal to the sum of the values of A & B, i.e. (a n- 1 …,a 1 a 0
2 +(b n- 1 …b 1 b 0
2 =(s n- 1 …s 1 s 0
2 Caution: Overflow, i.e. the sum is beyond the range of the representation. 8
Equality of addition (a n- 1 …,a 1 a 0
2 +(b n- 1 …b 1 b 0
2 =(s n- 1 …s 1 s 0
2 That is to say a n- 1
n- 1 +…+a 1
1 +a 0
0 +b n- 1
n- 1 +…+b 1
1 +b 0
0 =(a n- 1 +b n- 1
n- 1 +…+(a 1 +b 1
1 +(a 0 +b 0
0 =s n- 1
n- 1 +…+s 1
1 +s 0
0 10
b 2 b 1 b 0 Value 0 0 0 0 0 0 1 1 0 1 0 2 0 1 1 3 1 0 0 4 1 0 1 5 1 1 0 6 1 1 1 7 8 4 2 1 0 0 1 1 0 1 0 1 8 4 2 1 0 0 1 1 0 1 1 0
Examples: 11
a b (^) Carry Sum 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 0
13
id a b c (^) Carry Sum 0 0 0 0 0 0 1 0 0 1 0 1 2 0 1 0 0 1 3 0 1 1 1 0 4 1 0 0 0 1 5 1 0 1 1 0 6 1 1 0 1 0 7 1 1 1 1 1 Formula: a+b+c= 2xCarry + Sum 14
Gray: Frank Gray patented the code in 1947 A variation of binary code The code will be used for logic operation (CSE20, CSE140) Feature: only one bit changes for two consecutive numbers 16
17 id b 2 b 1 b 0 g 2 g 1 g 0 0 000 000 1 001 001 2 010 011 3 011 010 4 100 110 5 101 111 6 110 101 7 111 100 id b 1 b 0 g 1 g 0 0 00 00 1 01 01 2 10 11 3 11 10 2 digits 3 digits Note the difference of the first and last rows.
19 A 4-digit Gray code (g 3 g 2 g 1 g 0 ) at id=8 is written as (ref: previous page) A. (0101) B. (0110) C. (1100) D. None of the above
Construction of n-digit Gray code from n- 1 digit Gray code