Download presentation
Presentation is loading. Please wait.
Published byBetty Henderson Modified over 9 years ago
1
CSE 111 Representing Numeric Data in a Computer Slides adapted from Dr. Kris Schindler
2
Unsigned Binary Numbers Range: 0 2 n -1 where n is the number of bits Positional Notation Example: 101100 two
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: 39 ten
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 2 n - 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 2 23 100.1 2 x 2 23 Normalized 1.001 2 x 2 27 Exponent Bias = 127 127+26 = 153 = 10011001 2 Significand: 00100000000000000000000 Sign: 0 Number: 01001000100100000000000000000000
14
References J. Glenn Brookshear, Computer Science - An Overview, 11 th 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, 3 rd Edition, Morgan Kaufmann Publishers, Inc., 2005
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.