9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
Lec2 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Number system
1. ECE2030
Introduction to Computer Engineering
Lecture 2: Number System
Prof. Hsien-Hsin Sean LeeProf. Hsien-Hsin Sean Lee
School of Electrical and Computer EngineeringSchool of Electrical and Computer Engineering
Georgia TechGeorgia Tech
2. Decimal Number Representation
• Example: 90134 (base-10, used by Homo Sapien)
= 90000 + 0 + 100 + 30 + 4
= 9*104
+ 0*103
+ 1*102
+ 3*101
+ 4*100
• How did we get it?
901349013410
9013901310 44
90190110 33
909010 11
99 00
3. Generic Number Representation
• 90134
= 9*104
+ 0*103
+ 1*102
+ 3*101
+ 4*100
• A4A3A2A1A0 for base-10 (or radix-10)
= A4*104
+ A3*103
+A2*102
+A1*101
+A0*100
(A is coefficient; b is base)
• Generalize for a given number NN w/ base-bb
NN = An-1An-2 …A1A0
NN = An-1*bn-1
+ An-2*bn-2
+ … +A2*b2
+A0*b0
**Note that A < b**Note that A < b
11. 1
Base 16
• Decimal (base-10)
– (982)10
• Hexadecimal (base-16)
• Hey, what do we do when we
count to 10??
• 0
• 1
• 2
• 3
• 4
• 5
• 6
• 7
• 8
• 9
• 10
• 11
• 12
• 13
• 14
• 15
00
11
22
33
44
55
66
77
88
99
aa
bb
cc
dd
ee
ff
12. 2
Base 16
• (982)10= (3d6)16
• (3d6)16 can be written as (0011 1101 0110)2
• We use Base-16 (or Hex) a lot in computer
world
– Ex: A 32-bit address can be written as
0xfe8a7d200xfe8a7d20 ((0x0x is an abbreviation of Hex))
– Or in binary formOr in binary form
1111_1110_1000_1010_0111_1101_0010_00001111_1110_1000_1010_0111_1101_0010_0000
14. 4
Convert between different bases
• Convert a number base-x to base-y, e.g. (0100111)2 to (?)6
– First, convert from base-x to base-10 if x ≠ 10
– Then convert from base-10 to base-y
0100111 = 0∗26 + 1∗25 + 0∗24
+ 0∗23
+ 1∗22
+ 1∗21
+ 1∗20
= 39
39396
666 33
11 00
∴ (0100111)2 = (103)6
17. 7
Sign-magnitude
• Use the most significant bit (MSB)
to indicate the sign
– 00: positive, 11: negative
• Problem
– Representing zeros?
– Do not work in computation
• We will NOT use it in this course !
+0 000
+1 001
+2 010
+3 011
-3 111
-2 110
-1 101
0 100
18. 8
One’s Complement
• Complement (flip) each bit in a
binary number
• Problem
– Representing zeros?
– Do not always work in computation
• Ex: 111 + 001 = 000 → Incorrect !
• We will NOT use it in this course !
+0 000
+1 001
+2 010
+3 011
-3 100
-2 101
-1 110
0 111
19. 9
Two’s Complement
• ComplementComplement (flip) each bit in a
binary number and adding 1adding 1, with
overflow ignored
• Work in computation perfectly
• We will use it in this course !
011
100
One’s complement
3
101
Add 1
-3
010
One’s complement
101-3
011
Add 1
3
20. 0
Two’s Complement
• ComplementComplement (flip) each bit in a
binary number and adding 1adding 1, with
overflow ignored
• Work in computation perfectly
• We will use it in this course !
0 000
+1 001
-1 111
+2 010
-2 110
+3 011
-3 101
?? 100
100
011
One’s complement
100
Add 1
The same 100 represents
both 4 and -4
which is no good
21. 1
Two’s Complement
• ComplementComplement (flip) each bit in a
binary number and adding 1adding 1, with
overflow ignored
• Work in computation perfectly
• We will use it in this course !
0 000
+1 001
-1 1111
+2 010
-2 1110
+3 011
-3 1101
--4 1100
100
011
One’s complement
100
Add 1
MSB = 1 for negative
Number, thus 100
represents -4
22. 2
Range of Numbers
• An N-bit number
– Unsigned: 0 .. (2
N
-1)
– Signed: -2
N-1
.. (2
N-1
-1)
• Example: 4-bit
1110 (-8) 0111 (7)
Signed numbers
0000 (0) 1111 (15)Unsigned numbers
24. 4
Binary Computation
Unsigned arithmetic
101111 (47)
011111 (31)
---------------
001110 (78?? Due to overflow, note that
62 cannot be represented
by a 6-bit unsigned number)
The carry is
discarded
Signed arithmetic (w/ 2’s complement)
101111 (-17 since 2’s complement=010001)
011111 (31)
---------------
001110 (14)
The carry is
discarded
26. 6
Application of Two’s Complement
• The first Pocket CalculatorPocket Calculator “Curta”
used Two’s complement method for
subtractionsubtraction
• First complement the subtrahend
– Fill the left digits to be the same length
of the minuend
– Complemented number = (9 – digit)
• 4’s complement = 5
• 7’s complement = 2
• 0’s complement = 9
• Add 1 to the complemented number
• Perform an addition with the
minuend