Computer science
This presentation is the property of its rightful owner.
Sponsored Links
1 / 13

Computer SCIENCE PowerPoint PPT Presentation


  • 114 Views
  • Uploaded on
  • Presentation posted in: General

Data Representation and Machine Concepts. Computer SCIENCE. Section 1.6. Instructor: Lin Chen. Sept 2013. 1 Data Storage. 1.6 Storing Integers. Two’s Complement Excess Notation.

Download Presentation

Computer SCIENCE

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Computer science

Data Representation and Machine Concepts

Computer SCIENCE

Section 1.6

Instructor: Lin Chen

Sept 2013


Computer science

1 Data Storage

1.6 Storing Integers

Two’s Complement

Excess Notation

http://ocw.mit.edu/courses/aeronautics-and-astronautics/16-01-unified-engineering-i-ii-iii-iv-fall-2005-spring-2006/comps-programming/number_systems.pdf

Pearson Custom: Computer Science, Data Representation and Machine Concepts


Computer science

1.6 Storing Integers

Two’s Complement

Use a fixed number of bits to represent each of the values in the system

First bit is used to represent the sign, 1 represents negative number, 0 represent nonnegative number

A negative number is represented by inverting the bits of its corresponding positive number in each place, then add 1 to the inverted number

Suppose to use 4 bits to represent the number

01112 = 7 10

10002

+1

10012 = -7 10


Computer science

1.6 Storing Integers

Two’s Complement

Write the two’s complement notation for -6, -3, -1.


Computer science

1.6 Storing Integers

Two’s Complement

Four Bits


Computer science

1.6 Storing Integers

Two’s Complement

Addition

7 – 2 = 7 + (-2) = ?

0111

1110

+

10101


Computer science

1.6 Storing Integers

Two’s Complement

Addition

7 – 2 = 7 + (-2) = ?

0111

1110

+

10101

Use four bits

01012 = 510


Computer science

1.6 Storing Integers

Two’s Complement

Use two’s complement notation to calculate:

7 – 5 = ?

-3 – 4 = ?

6 – 4 = ?

-2 – 5 = ?


Computer science

1.6 Storing Integers

Two’s Complement

What is the range of numbers that can be represented using the 2’s complement?

Answer: 2N-1 – 1 to -2N-1

N is the number of bits

Three bits: 3 to -4

Four bits: 7 to -8

Eight bits: ?


Computer science

1.6 Storing Integers

Two’s Complement

List all the number with the two’s complement notation using 3 bits

Express 16 - -16 with the two’s complement notation using 8 bits


Computer science

1.6 Storing Integers

Two’s Complement

Overflow

Calculate 5 + 4 with two’s complement notation using 4 bits


Computer science

1.6 Storing Integers

Excess Notation

Steps:

Add the excess value 2N-1 to the number, where N is the number of bits used

Convert the resulting number into binary format

Suppose use 4 bits

2

0010

+

8

=

-6

24-1


Computer science

1.6 Storing Integers

Two’s Complement

Write -8 to 7 with excess notation with 4 bits

Write -4 to 3 with excess notation with 3 bits


  • Login