Download presentation
Presentation is loading. Please wait.
Published byDulcie Marshall Modified over 9 years ago
1
Chapter 1 Data Storage(3) Yonsei University 1 st Semester, 2015 Sanghyun Park
2
Outline Bits and their storage(prev. file) Main memory(prev. file) Mass storage(prev. file) Representing information as bit patterns(prev. file) Binary system(prev. file) Storing integers Storing fractions
3
Representing Integers Unsigned integers can be represented in base ___ ______ integers = numbers that can be positive or negative Sign and magnitude notation Two’s complement notation Excess notation
4
Sign and Magnitude Notation Left hand bit is used to determine the ___ of the number Left hand bit 0 = positive number0010 = +2 Left hand bit 1 = negative number1010 = -2 Using 4 bits with sign and magnitude, largest positive number represented is __ (-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7) ___ values overall can be represented +2 added to -2 using regular binary addition does ___ _____ to 0
5
Two’s Complement Notation (1/2) For a positive number, the two’s complement representation is _____ For a negative number, ___________ positive value and then ____ 1 3 in two’s complement is 011 -3 in two’s complement is 100 + 1 = 101
6
Two’s Complement Notation (2/2) What is the decimal value of 1010 in two’s complement? It is a negative number since left hand bit is 1 Complement it and add 1: 0101 + 1 = 0110 (+6) Therefore the decimal value is -6
7
Two’s Complement Addition
8
Overflow Problem Try adding 5 + 4 in 4-bit two’s complement notation Result is negative value (-7) Such an error is called ________ When using two’s complement notation, this might occur when adding two ________ values or when adding two ________ values Normally integers are represented in 32-bit patterns, allowing for positive values as large as 2,147,483,647
9
Excess Notation (1/3) Excess four notation All positive numbers begin with 1 All negative numbers begin with 0 0 is represented as ___ Smallest negative number is ___ Largest positive number is ___ Why 4? (2 #of bits –1 ) = 2 3-1 = 4
10
Excess Notation (2/3)
11
Excess Notation (3/3) What is the decimal value of 101 in excess four notation? 101 if interpreted unsigned is 5 101 in excess four notation is (5-4) = 1 What is the excess four notation for decimal value 3? Add four: 3+4 = 7 Represent it in 3-bit binary pattern = 111
12
Excess Eight Notation
13
Storing Fractions (1/6) Need to represent ______ and ______ of radix point Use ___________ notation 1 bit:Sign bit (0 positive, 1 negative) 3 bits:Exponent (encodes position of radix point in excess four ) 4 bits:Mantissa (encodes number)
14
Storing Fractions (2/6) What is the decimal value of 01101011 in floating-point notation? First bit is 0, then positive Exponent is 110 and mantissa is 1011 Extract mantissa and place a radix point on its left side 0.1011 Extract exponent and interpret as excess four notation 110 in excess four is +2 (make sure?) +2 exponent means move radix point to the right by two bits (a negative exponent means move radix to left) 0.1011 becomes 10.11
15
Storing Fractions (3/6) What is the decimal value of 10111100 in floating-point notation? First bit is 1, then negative Exponent is 011and mantissa is 1100 Extract mantissa and place a radix point on its left side 0.1100 Extract exponent and interpret as excess four notation 011 in excess four is -1 (make sure?) -1 exponent means move radix point to the left by 1 bit 0.1100 becomes 0.01100
16
Storing Fractions (4/6) What is the floating point notation of the number ? Express the number in binary to obtain 1.001 (make sure?) Copy bit pattern into mantissa field from left to right starting with the leftmost 1 in binary representation Mantissa is 1001 Compute exponent to get 1.001 from.1001 (imagine mantissa with radix point at its left) Need to move radix point to right one bit Exponent is +1 Express exponent in excess four notation: 1+4 = 5 (101) Therefore, 01011001
17
Storing Fractions (5/6) What is the floating point notation of the number ? Express number in binary to obtain 0.01 Copy bit pattern into mantissa field from left to right starting with the leftmost 1 in binary representation Mantissa is 1000 (you append zeros to fill the 4-bit mantissa) Compute exponent to get 0.01 from 0.1000 Need to move radix point to left one bit Exponent is -1 Express exponent in excess four notation: -1+4 = 3 (011) Therefore, 10111000
18
Storing Fractions (6/6) What is the floating point notation of the number ? We end up with the bit pattern 01101010, which represents 2 1 /2 instead of 2 5 /8 What has occurred is called a truncation error or round-off error
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.