Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
ECE2030
Introduction to Computer Engineering
Lecture 2: Number System
Prof. Hsien-Hsin Sean LeeProf. Hsien-Hsin Sean Lee
S...
Decimal Number Representation
• Example: 90134 (base-10, used by Homo Sapien)
= 90000 + 0 + 100 + 30 + 4
= 9*104
+ 0*103
+...
Generic Number Representation
• 90134
= 9*104
+ 0*103
+ 1*102
+ 3*101
+ 4*100
• A4A3A2A1A0 for base-10 (or radix-10)
= A4*...
Counting numbers with base-bb
00
11
22
33
44
55
66
77
88
99
1010
1111
1212
1313
1414
1515
1616
1717
1818
1919
Base-10
9090...
How about base-22
00
11
1010
1111
100100
101101
110110
111111
10001000
10011001
10101010
10111011
11001100
11011101
111011...
How about base-22
00
11
1010
1111
100100
101101
110110
111111
10001000
10011001
10101010
10111011
11001100
11011101
111011...
How about base-22
00 = 0= 0
11 = 1= 1
1010 = 2= 2
1111 = 3= 3
100100 = 4= 4
101101 = 5= 5
110110 = 6= 6
111111 = 7= 7
1000...
Derive Numbers in Base-2
• Decimal (base-10)
– (25)10
• Binary (base-2)
– (11001)2
• Exercise
25252
12122 11
662 00
332 00...
Base-2
• Decimal (base-10)
– (982)10
• Binary (base-2)
– (1111010110)2
• Exercise
0
Base 8
• Decimal (base-10)
– (982)10
• Octal (base-8)
– (1726)8
• Exercise
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...
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
wor...
3
Number Examples with Different Bases
• Decimal (base-10)
– (982)10
• Binary (base-2)
– (01111010110)2
• Octal (base-8)
–...
4
Convert between different bases
• Convert a number base-x to base-y, e.g. (0100111)2 to (?)6
– First, convert from base-...
Base-b Addition
6
Negative Number Representation
• Options
– Sign-magnitude
– One’s Complement
– Two’s Complement (we use this in this cou...
7
Sign-magnitude
• Use the most significant bit (MSB)
to indicate the sign
– 00: positive, 11: negative
• Problem
– Repres...
8
One’s Complement
• Complement (flip) each bit in a
binary number
• Problem
– Representing zeros?
– Do not always work in...
9
Two’s Complement
• ComplementComplement (flip) each bit in a
binary number and adding 1adding 1, with
overflow ignored
•...
0
Two’s Complement
• ComplementComplement (flip) each bit in a
binary number and adding 1adding 1, with
overflow ignored
•...
1
Two’s Complement
• ComplementComplement (flip) each bit in a
binary number and adding 1adding 1, with
overflow ignored
•...
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) 0...
3
Binary Computation
010001 (17=16+1)
001011 (11=8+2+1)
---------------
011100 (28=16+8+4)
Unsigned arithmetic
010001 (17=...
4
Binary Computation
Unsigned arithmetic
101111 (47)
011111 (31)
---------------
001110 (78?? Due to overflow, note that
6...
BACKUP
6
Application of Two’s Complement
• The first Pocket CalculatorPocket Calculator “Curta”
used Two’s complement method for
...
7
Examples
• 13 – 7
– Two’s complement of 07 = 92 + 1 = 93
– 13 + 93 = 06 (ignore the leftmost carry digit)
• 817 – 123
– ...
Upcoming SlideShare
Loading in …5
×
Upcoming SlideShare
Lec20 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Data Path
Next
Download to read offline and view in fullscreen.

0

Share

Download to read offline

Lec2 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Number system

Download to read offline

Number conversion

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Lec2 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Number system

  1. 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. 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. 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
  4. 4. Counting numbers with base-bb 00 11 22 33 44 55 66 77 88 99 1010 1111 1212 1313 1414 1515 1616 1717 1818 1919 Base-10 9090 9191 9292 9393 9494 9595 9696 9797 9898 9999 ….. 100100 101101 102102 103103 104104 105105 106106 107107 108108 109109 How about Base-8 00 11 22 33 44 55 66 77 1010 1111 1212 1313 1414 1515 1616 1717 2020 2121 2222 2323 2424 2525 2626 2727 7070 7171 7272 7373 7474 7575 7676 7777 ….. 100100 101101 102102 103103 104104 105105 106106 107107 2020 2121 2222 2323 2424 2525 2626 2727 2828 2929
  5. 5. How about base-22 00 11 1010 1111 100100 101101 110110 111111 10001000 10011001 10101010 10111011 11001100 11011101 11101110 11111111
  6. 6. How about base-22 00 11 1010 1111 100100 101101 110110 111111 10001000 10011001 10101010 10111011 11001100 11011101 11101110 11111111
  7. 7. How about base-22 00 = 0= 0 11 = 1= 1 1010 = 2= 2 1111 = 3= 3 100100 = 4= 4 101101 = 5= 5 110110 = 6= 6 111111 = 7= 7 10001000 = 8= 8 10011001 = 9= 9 10101010 = 10= 10 10111011 = 11= 11 11001100 = 12= 12 11011101 = 13= 13 11101110 = 14= 14 11111111 = 15= 15 BinaryBinary == DecimalDecimal
  8. 8. Derive Numbers in Base-2 • Decimal (base-10) – (25)10 • Binary (base-2) – (11001)2 • Exercise 25252 12122 11 662 00 332 00 11 11
  9. 9. Base-2 • Decimal (base-10) – (982)10 • Binary (base-2) – (1111010110)2 • Exercise
  10. 10. 0 Base 8 • Decimal (base-10) – (982)10 • Octal (base-8) – (1726)8 • Exercise
  11. 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. 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
  13. 13. 3 Number Examples with Different Bases • Decimal (base-10) – (982)10 • Binary (base-2) – (01111010110)2 • Octal (base-8) – (1726)8 • Hexadecimal (base-16) – (3d6)16 • Others examples: – base-9 = (1321)9 – base-11 = (813)11 – base-17 = (36d)17
  14. 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
  15. 15. Base-b Addition
  16. 16. 6 Negative Number Representation • Options – Sign-magnitude – One’s Complement – Two’s Complement (we use this in this course)
  17. 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. 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. 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. 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. 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. 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
  23. 23. 3 Binary Computation 010001 (17=16+1) 001011 (11=8+2+1) --------------- 011100 (28=16+8+4) Unsigned arithmetic 010001 (17=16+1) 101011 (43=32+8+2+1) --------------- 111100 (60=32+16+8+4) Signed arithmetic (w/ 2’s complement) 010001 (17=16+1) 101011 (-21: 2’s complement=010101=21) --------------- 111100 (2’s complement=000100=4, i.e. -4)
  24. 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
  25. 25. BACKUP
  26. 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
  27. 27. 7 Examples • 13 – 7 – Two’s complement of 07 = 92 + 1 = 93 – 13 + 93 = 06 (ignore the leftmost carry digit) • 817 – 123 – Two’s complement of 123 = 876 + 1 = 877 – 817 + 877 = 694 (ignore the leftmost carry digit) • 78291 – 4982 – Two’s complement of 04982 = 95017 + 1 = 95018 – 78291 + 95018 = 73309 (ignore the leftmost carry digit)

Number conversion

Views

Total views

801

On Slideshare

0

From embeds

0

Number of embeds

14

Actions

Downloads

45

Shares

0

Comments

0

Likes

0

×