CSC 2400 Announcements q HW 1 assigned (Due Wednesday) q Sign up for - - PowerPoint PPT Presentation

csc 2400 announcements
SMART_READER_LITE
LIVE PREVIEW

CSC 2400 Announcements q HW 1 assigned (Due Wednesday) q Sign up for - - PowerPoint PPT Presentation

CSC 2400 Announcements q HW 1 assigned (Due Wednesday) q Sign up for Piazza (30/47) CSC 2400: Computer Systems Number Systems Analog vs. Digital System q Analog Signals - Value varies continuously q Digital Signals - Value limited to a finite set


slide-1
SLIDE 1

CSC 2400 Announcements

q HW 1 assigned (Due Wednesday) q Sign up for Piazza (30/47)

slide-2
SLIDE 2

CSC 2400: Computer Systems Number Systems

slide-3
SLIDE 3

Analog vs. Digital System

q Analog Signals

  • Value varies continuously

q Digital Signals

  • Value limited to a finite set
  • Digital systems more robust

q Binary Signals

  • Has at most 2 values
  • Used to represent bit values
  • Bit time T needed to send 1 bit
slide-4
SLIDE 4

Why Bits (Binary Digits)?

q Computers are built using digital circuits

  • Inputs and outputs can have only two values
  • True (high voltage) or false (low voltage)
  • Represented as 1 and 0

q Can represent many kinds of information

  • Boolean (true or false)
  • Numbers (23, 79, …)
  • Characters (‘a’, ‘z’, …)
  • Pixels, sounds
  • Internet addresses
slide-5
SLIDE 5

Coding

q A single binary input can have two values: 1 or 0 q More bits = more combinations

0 0 0 1 1 0 1 1

slide-6
SLIDE 6

Coding

q How many values can you represent on 3 bits? q What about n bits?

slide-7
SLIDE 7

Binary Numbers

q How do you figure out what the value of 1110two is?

  • Same way you do for 4173ten, for instance

q Decimal (base 10)

  • Each digit represents a power of 10
  • 4173ten = 4 x 103 + _____________________

q Binary (base 2)

  • Each bit represents a power of 2
  • 1110two = 1 x 23 + _____________________ = 14ten
slide-8
SLIDE 8

Binary Numbers

q How do you figure out what the value of 1110two is?

  • Same way you do for 4173ten, for instance

q Decimal (base 10)

  • Each digit represents a power of 10
  • 4173ten = 4 x 103 + 1 x 102 + 7 x 101 + 3 x 100

q Binary (base 2)

  • Each bit represents a power of 2
  • 1110two = 1 x 23 + 1 x 22 + 1 x 21 + 0 x 20 = 14ten
slide-9
SLIDE 9

1 10 11 _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____

Counting in Binary

0 = 1 = 2 = 3 = 4 = 5 = 6 = 7 = 8 = 9 = 10 = 11 = 12 = 13 = 14 = 15 = 16 = 17 = 18 =

Base 10 Base 2

slide-10
SLIDE 10

1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10000 10001 10010

Counting in Binary

0 = 1 = 2 = 3 = 4 = 5 = 6 = 7 = 8 = 9 = 10 = 11 = 12 = 13 = 14 = 15 = 16 = 17 = 18 = 0000 0000 000 000 00 00 00 00

Base 10 Base 2

slide-11
SLIDE 11

Binary (Base 2) to Decimal

q Sum up (bit*weight):

28 27 26 25 24 23 22 21 20 256 128 64 32 16 8 4 2 1 1 1 1 1 1 1 1

10000011two = _______________________________ten ? 101001100two = _______________________________ten ? Binary Weights

slide-12
SLIDE 12

Binary (Base 2) to Decimal

q Sum up (bit*weight):

28 27 26 25 24 23 22 21 20 256 128 64 32 16 8 4 2 1 1 1 1 1 1 1 1

10000011two = _131___________________________ten ? 101001100two = _332___________________________ten ? Binary Weights

slide-13
SLIDE 13

Powers of 2

q Memorize!

210 29 28 27 26 25 24 23 22 21 20 1024 512 256 128 64 32 16 8 4 2 1 280 270 260 250 240 230 220 210 Yotta Zetta Exa Peta Tera Giga Mega Kilo Y Z E P T G M K

slide-14
SLIDE 14

Number Systems

Base Character Set

2 {0,1} 3 {0,1,2} 4 {0,1,2,3} 5 {0,1,2,3,4} 6 {0,1,2,3,4,5} 7 {0,1,2,3,4,5,6} 8 {0,1,2,3,4,5,6,7} 9 {0,1,2,3,4,5,6,7,8} 10 {0,1,2,3,4,5,6,7,8,9} 11 {0,1,2,3,4,5,6,7,8,9,A} 12 {0,1,2,3,4,5,6,7,8,9,A,B} 13 {0,1,2,3,4,5,6,7,8,9,A,B,C} 14 {0,1,2,3,4,5,6,7,8,9,A,B,C,D} 15 {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E} 16 {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}

slide-15
SLIDE 15

1 2 3 4 5 6 7 10 __ __ __ __ __ __ __ __ __ __

Counting in Octal

0 = 1 = 2 = 3 = 4 = 5 = 6 = 7 = 8 = 9 = 10 = 11 = 12 = 13 = 14 = 15 = 16 = 17 = 18 =

Base 10 Base 8

slide-16
SLIDE 16

1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 20 21 22

Counting in Octal

0 = 1 = 2 = 3 = 4 = 5 = 6 = 7 = 8 = 9 = 10 = 11 = 12 = 13 = 14 = 15 = 16 = 17 = 18 = 00 00 00 00 00 00 00 00

Base 10 Base 8

slide-17
SLIDE 17

Octal (Base 8) to Decimal

q Sum up (digit*weight):

84 83 82 81 80 4096 512 64 8 1 2 5 7 1 2 2 6

2578 = _________________________________10 ? 102268 = _________________________________10 ? Octal weights

slide-18
SLIDE 18

Octal (Base 8) to Decimal

q Sum up (digit*weight):

84 83 82 81 80 4096 512 64 8 1 2 5 7 1 2 2 6

2578 = _175_____________________________10 ? 102268 = _4246____________________________10 ? Octal weights

slide-19
SLIDE 19

1 2 3 4 5 6 7 8 9 A B C D E F 10 __ __

Counting in Hexadecimal

0 = 1 = 2 = 3 = 4 = 5 = 6 = 7 = 8 = 9 = 10 = 11 = 12 = 13 = 14 = 15 = 16 = 17 = 18 =

Base 10 Base 16

slide-20
SLIDE 20

1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12

Counting in Hexadecimal

0 = 1 = 2 = 3 = 4 = 5 = 6 = 7 = 8 = 9 = 10 = 11 = 12 = 13 = 14 = 15 = 16 = 17 = 18 = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Base 10 Base 16

slide-21
SLIDE 21

Hexadecimal (Base 16) to Decimal

q Sum up (hex digit*weight):

163 162 161 160 4096 256 16 1 A 2 B 1 4 A 6

A2B16 = _________________________________10 ? 14A616 = _________________________________10 ? Hexadecimal Weight

slide-22
SLIDE 22

Hexadecimal (Base 16) to Decimal

q Sum up (hex digit*weight):

163 162 161 160 4096 256 16 1 A 2 B 1 4 A 6

A2B16 = _2603____________________________10 ? 14A616 = _5286____________________________10 ? Hexadecimal Weight

slide-23
SLIDE 23

Decimal to Binary

q Use the Placement Method

1024 512 256 128 64 32 16 8 4 2 1

Powers of 2 15510 = _________________________________ 2 ? 128 goes into 155 once leaving 27 to be placed

1 ? ? ? ? ? ? ?

64 and 32 are too big (make them 0) 16 goes in once leaving 11

1 1 ? ? ? ?

and so on

slide-24
SLIDE 24

Decimal to Binary

q Use the Placement Method

1024 512 256 128 64 32 16 8 4 2 1

Powers of 2 15510 = _10011011________________________ 2 ? 128 goes into 155 once leaving 27 to be placed

1 ? ? ? ? ? ? ?

64 and 32 are too big (make them 0) 16 goes in once leaving 11

1 1 ? ? ? ?

and so on

slide-25
SLIDE 25

You Try It …

1024 512 256 128 64 32 16 8 4 2 1

Powers of 2 58310 = _________________________________ 2 ?

slide-26
SLIDE 26

You Try It …

1024 512 256 128 64 32 16 8 4 2 1

Powers of 2 58310 = _1001000111______________________ 2 ?

slide-27
SLIDE 27

Hexadecimal Benefits

q It is often convenient to write binary (base-2) numbers

as hexadecimal (base-16) numbers instead

  • fewer digits – four bits per hex digit
  • less error prone – easy to corrupt long string of 1’s and 0’s

Binary Hex Decimal

0000 0001 1 1 0010 2 2 0011 3 3 0100 4 4 0101 5 5 0110 6 6 0111 7 7

Binary Hex Decimal

1000 8 8 1001 9 9 1010 A 10 1011 B 11 1100 C 12 1101 D 13 1110 E 14 1111 F 15

slide-28
SLIDE 28

Converting from Binary to Hexadecimal

q Every four bits is a hex digit

  • start grouping from right-hand side

011101010001111010011010111 __ __ __ __ __ __ 3

This is not a new machine representation, just a convenient way to write the number

slide-29
SLIDE 29

Converting from Binary to Hexadecimal

q Every four bits is a hex digit.

  • start grouping from right-hand side

011101010001111010011010111 7 D 4 F 8 A 3

This is not a new machine representation, just a convenient way to write the number

slide-30
SLIDE 30
  • 1. Convert the hex value 0x7A8BF7D6 into its binary equivalent:
  • 2. Convert the binary

10 0110 1110 1001 0100 1100 0101 11112

to hex:

Exercises

0111 1010 ____ ____ ____ ____ ____ ____ 0010 0110 1110 1001 0100 1100 0101 1111 6 __ __ __ __ __ __ 2 7 A 8 B F 7 D 6

slide-31
SLIDE 31
  • 1. Convert the hex value 0x7A8BF7D6 into its binary equivalent:
  • 2. Convert the binary

10 0110 1110 1001 0100 1100 0101 11112

to hex:

Exercises

0111 1010 1000 1011 1111 0111 1101 0110 0010 0110 1110 1001 0100 1100 0101 1111 6 E 9 4 C 5 F 2 7 A 8 B F 7 D 6

slide-32
SLIDE 32
  • 3. Convert from binary to octal:

10 111 010 100 110 001 011 1112

Exercises (contd.)

010 111 010 100 110 001 011 111 __ __ __ __ __ __ __ 2

slide-33
SLIDE 33
  • 3. Convert from binary to octal:

10 111 010 100 110 001 011 1112

Exercises (contd.)

010 111 010 100 110 001 011 111 7 2 4 6 1 3 7 2

slide-34
SLIDE 34

Number Systems

q The binary, hexadecimal (hex) and octal system share

  • ne common feature
  • they are all based on powers of 2

q Each digit in the hex system is equivalent to a four-digit

binary number and each digit in the octal system is equivalent to a 3-digit binary number.

slide-35
SLIDE 35

Practice

Hex Decimal Binary 10 240 11111111

slide-36
SLIDE 36

Practice

Hex Decimal Binary 10 16 10000 F0 240 11110000 FF 255 11111111

slide-37
SLIDE 37

Arithmetic Operations

slide-38
SLIDE 38

Decimal Addition

q From right to left, we add each pair of digits q We write the sum, and add the carry to the next column

1 9 8 + 2 6 4 Sum Carry

2 1 6 1 4

slide-39
SLIDE 39

8 5 + E D

q Hex addition is similar to decimal addition except that each

hex digit has a range of ‘0’ to ‘F’ instead of ‘0’ to ‘9’, and a “carry out” occurs when the sum of hex digits in a particular column exceeds ‘F’ (15 decimal).

q Examples:

Hex Addition

A C 3 + 2 7 C 7 + 2 A E 1

1

F 2

1

1 7 3 B 9 A + D 2 E 6

1

8

1

E 1 0

slide-40
SLIDE 40

Binary Addition

q From right to left, we add each pair of bits

0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10

q We write the sum, and add the carry to the next column

1 9 8 + 2 6 4 Sum Carry 1 1 + 1 Sum Carry

2 1 6 1 4 Base 10 (ten) Base 2

slide-41
SLIDE 41

Summary

q Number Systems

  • Binary
  • Octal
  • Decimal
  • Hexadecimal

q Arithmetic Operations

  • Addition in binary and hex systems
slide-42
SLIDE 42

Decimal Subtraction

q If you subtract a larger digit from a smaller digit, borrow 10 (ten)

from the left

2 6 0

  • 7 8

/

2 8

/

5

1

10

1 15

slide-43
SLIDE 43

D 3 5 F

  • 4 3 B 6

/

q Hex subtraction is similar to decimal subtraction except that if

the subtrahend is greater than the minuend, we must “borrow” 16 (10 hex) from the previous digit.

q Examples:

Hex Subtraction

D B 3

  • 3 6

C A

  • 2 5

7 5 A

/

9 A

13

A

/

15 12

2 C

F 8

slide-44
SLIDE 44

1 0

  • 0 1

1 1 0 0

  • 1 0 0 1

/

q Similar to decimal subtraction q If you subtract 1 from 0, “borrow” 2 (10 binary) from the

previous bit.

q Examples:

Binary Subtraction

1 1 1

  • 0 1

1

/

1 1

10

/

10 1 10