1 / 13

Computer SCIENCE

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.

thom
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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Representation and Machine Concepts Computer SCIENCE Section 1.6 Instructor: Lin Chen Sept 2013

  2. 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

  3. 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

  4. 1.6 Storing Integers Two’s Complement Write the two’s complement notation for -6, -3, -1.

  5. 1.6 Storing Integers Two’s Complement Four Bits

  6. 1.6 Storing Integers Two’s Complement Addition 7 – 2 = 7 + (-2) = ? 0111 1110 + 10101

  7. 1.6 Storing Integers Two’s Complement Addition 7 – 2 = 7 + (-2) = ? 0111 1110 + 10101 Use four bits 01012 = 510

  8. 1.6 Storing Integers Two’s Complement Use two’s complement notation to calculate: 7 – 5 = ? -3 – 4 = ? 6 – 4 = ? -2 – 5 = ?

  9. 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: ?

  10. 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

  11. 1.6 Storing Integers Two’s Complement Overflow Calculate 5 + 4 with two’s complement notation using 4 bits

  12. 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

  13. 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

More Related