Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE20 Lecture 2: Number Systems: Binary Numbers, Gray Code, and Negative Numbers CK Cheng 1.

Similar presentations


Presentation on theme: "CSE20 Lecture 2: Number Systems: Binary Numbers, Gray Code, and Negative Numbers CK Cheng 1."— Presentation transcript:

1 CSE20 Lecture 2: Number Systems: Binary Numbers, Gray Code, and Negative Numbers CK Cheng 1

2 Number Systems 1.Introduction 2.Binary Numbers 3.Gray code 4.Negative Numbers 5.Residual Numbers 2

3 2. Binary Numbers b2b2 b1b1 b0b0 Value 0000 0011 0102 0113 1004 1015 1106 1117 8421 0011 0101 1000 3 + 5 = 8 8421 0011 0110 1001 3 + 6 = 9 + + Examples: (3) (5) (8) (3) (6) (9) This is a non-redundant number system 3

4 2. Binary Cont. abCarrySum 0000 0101 1001 1110 idabcCarrySum 000000 100101 201001 301110 410001 510110 611010 711111 2*0 + 0=000id 0 2*0 + 1=001id 1 2*1 + 0=110id 6 2*1 + 1=111id 7 RULE: 2 x Carry + Sum = a + b + c 4

5 3. Gray Code reflection Low power (reliability) when the numbers are consecutive in series. The idea is to only change ONE bit at a time. e.g. addresses, analog signals NOTE: Not for arithmetic operations (the rule is too complicated) 5

6 4. Negative Numbers Given a positive integer x, represent the negative integer –x in (b n-1, …, b 0 ) (i) Signed bit system b n-1 =1: negative, (b n-2,…,b 0 )=x. (ii) One's Complement Present 2 n - 1 - x in binary. (iii) Two's Complement Present 2 n – x in binary. Ignore bit b n. 6

7 4. Negative Numbers NOTE: Back to binary system idb3b3 b2b2 b1b1 b0b0 SignedOne'sTwo's 00000000 10001111 20010222 30011333 40100444 50101555 60110666 70111777 81000-0-7-8 91001-6-7 101010-2-5-6 111011-3-4-5 121100-4-3-4 131101-5-2-3 141110-6-2 151111-7-0 (i) Signed bit - x b3: negative (ii) One's Complement 2 n - 1 - x (iii) Two's Complement 2 n - x n is the number of bits (in this case n=4) One's ComplementTwo's Complement 8 = 16 - 1 - x8 = 16 - x 9 = 16 - 1 – x Use the above formulas to solve for x when number is negative Two's (b 4 )b3b3 b2b2 b1b1 b0b0 710111 610110 510101 410100 310011 210010 110001 010000 01111 -201110 -301101 -401100 -501011 -601010 -701001 -801000 Deriving One’s and Two’sReverse Derivation 7


Download ppt "CSE20 Lecture 2: Number Systems: Binary Numbers, Gray Code, and Negative Numbers CK Cheng 1."

Similar presentations


Ads by Google