1 / 14

Representing Numeric Data in a Computer

This presentation covers topics such as unsigned binary numbers, signed binary numbers, two's complement, and floating point representation. It explains how to convert decimal numbers to binary and vice versa.

dellam
Télécharger la présentation

Representing Numeric Data in a Computer

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. CSE 111 Representing Numeric Data in a Computer Slides adapted from Dr. Kris Schindler

  2. Unsigned Binary Numbers • Range: 02n-1 • where n is the number of bits • Positional Notation • Example: 101100two

  3. Unsigned Binary Numbers • How do we convert from a decimal number to a binary number? • Continue until q=0

  4. Unsigned Binary Numbers • How do we convert from a decimal number to a binary number? • Example: 39ten

  5. Bit Positions • MSB • Most Significant Bit • Leftmost Bit Position • LSB • Least Significant Bit • Rightmost Bit Position

  6. Signed Binary Numbers • The most significant bit (leftmost) represents the sign • Negative (-): 1 • Positive (+): 0

  7. Signed Binary Numbers • Computers represent signed numbers using two’s complement notation

  8. Signed Binary Numbers • Two’s Complement • Representation of a negative binary number • Consider an n-bit number, x • The two’s complement of the number is 2n - x • This process is called taking the two’s complement of a number • Taking the two’s complement of a number negates it

  9. Signed Binary Numbers • Two’s Complement • Shortcut for taking the two’s complement of a number • Start at the least significant (rightmost) bit and move left (toward the most significant bit) • Keep every bit until you reach the first 1 • Keep that 1 • Invert every bit (01,1  0) after the first 1 as you continue to move left

  10. Signed Binary Numbers • Two’s Complement • Examples: • -4 • Take the two’s complement of 4 (00000100) • 11111100 =-4 • -9 • Take the two’s complement of 9 (00001001) • 11110111 =-9 • Since the above are negative, taking the two’s complement will allow you to determine the magnitude, which is the positive equivalent

  11. Signed Binary Numbers • Two’s Complement • Examples: • +6 • Since the number is positive, you don’t need to take the two’s complement • 000000110 =+6 • +18 • Since the number is positive, you don’t need to take the two’s complement • 000010010 =+18

  12. Signed Binary Numbers • Two’s Complement • Since taking the two’s complement of a number negates it, taking the two’s complement twice gives you the original number back • Example: • +12 is represented by 00001100 • Taking the two’s complement results in -12 (11110100) • Taking the two's complement of -12 results in +12 (00001100)

  13. Floating Point • Very large/small numbers • Fractions • Example • 8.5 x 223 • 100.12x 223 • Normalized • 1.0012x 227 • Exponent • Bias = 127 • 127+26 = 153 = 100110012 • Significand: 00100000000000000000000 • Sign: 0 • Number: 01001000100100000000000000000000

  14. References • J. Glenn Brookshear, Computer Science - An Overview, 11th edition, Addison-Wesley as an imprint of Pearson, 2012 • Donald D. Givone, Digital Principles and Design, McGraw-Hill, 2003 • John L. Hennessy and David A. Patterson, Computer Organization and Design, The Hardware/Software Interface, 3rd Edition, Morgan Kaufmann Publishers, Inc., 2005

More Related