DATA
DATA STORAGE STORAGE DATA
DATA STORAGE STORAGE
CHAPTER III CHAPTER III
LECTURE I LECTURE III LECTURE I LECTURE III
Week
Week 4 4
Different system for representing (storing) integer in Different system for representing (storing) integer in
memory memory Unsigned Representation
Unsigned Representation
Unsigned integer is an integer that can never be Unsigned integer is an integer that can never be negative and take only
negative and take only 0 0 or positive value. Its range is or positive value. Its range is between
between 0 0 and positive infinity.and positive infinity.
We use the maximum unsigned integer to define the We use the maximum unsigned integer to define the number of bits we can use to store this number.
number of bits we can use to store this number.
Example:
Example:a p e:a p e:
If we have
If we have 4 4 bits so the maximum unbits so the maximum un--singed integer singed integer
Storing unsigned integer: we use the following Storing unsigned integer: we use the following steps
steps 1
1) Integer is changed to binary ) Integer is changed to binary 2
2) If the number of bits is less than n, ) If the number of bits is less than n, 0 0s are s are added to the left of the binary integer so that added to the left of the binary integer so that added to the left of the binary integer so that added to the left of the binary integer so that there is a total of n b its
there is a total of n b its 3
3) f h ) f h b b f bi f bi i i h h h h 3
3) If the number of bits is greater than n, then ) If the number of bits is greater than n, then the integer cannot be stored, and in this case the integer cannot be stored, and in this case we will have an overflow.
we will have an overflow.
Example:
Example:pp
Assume we have a memory location with
Assume we have a memory location with 88--bit store the bit store the following numbers
following numbers 1
1) ) 7 7 n=
n=88bit bit 88 77 66 55 44 33 22 11 Change
Change 7 7 to binary to binary 1 1 11 1 1 Add five bits to the left:
Add five bits to the left: 00 0 0 0 00 0 0 0 11 11 11 Add five bits to the left:
Add five bits to the left: 0 0 0 0 0 1 1 10 0 0 0 0 1 1 1
2
2) Change ) Change 258 258 to binaryto binary
1 1 2
2 3
3 4
4 5
5 6
6 7
7 8
n= 8
n=88bit bit 88 77 66 55 44 33 22 11 Change
Change 258 258 into binary into binary
0 0 1
1 0
0 0
0 0
0 0
0 0
0 0
0
1
Overflow Overflow
Due to size limitation, the allocated number of bits and Due to size limitation, the allocated number of bits and the range of integers that can be represented is limited.
the range of integers that can be represented is limited.
In an n
In an n--bit memory location we can only store an bit memory location we can only store an unsigned integer between
unsigned integer between 0 0 and and 22nn--11