Number Representation: CHAPTER 3 - Part 3
Number Representation: CHAPTER 3 - Part 3
Number Representation: CHAPTER 3 - Part 3
REPRESENTATION
CHAPTER 3 – part 3
ONE’S COMPLEMENT
REPRESENTATION
CHAPTER 3 – part 3
Integer Representation
Integer
Representation
Unsigned Signed
To represent
positive number same way as UNSIGNED Integer
# of Bits Range
--------- -------------------------------------------------------
8 -127 -0 +0 +127
16 -32767 -0 +0 +32767
32 -2,147,483,647 -0 +0 +2,147,483,647
One’s complement integers
In an 8-bit allocation:
+0 00000000
-0 10000000
One’s complement integers
Solution
the leftmost bit is 1, so the number is negative
Complement the number 11110110 00001001
the complement in decimal is 9
So the answer is -9
One’s complement Applications
The one’s complement representation is not used now
by computers because:
Integer
Representation
Unsigned Signed
It’s…
The most common
The most important
The most widely used representation today
Two’s complement integers
# of Bits Range
--------- -------------------------------------------------------
8 -128 -0 +0 +127
16 -32768 -0 +0 +32767
32 -2,147,483,648 -0 +0 +2,147,483,647
Two’s complement integers
In an 8-bit allocation:
0 00000000
Two’s complement integers
Solution
the leftmost bit is 1, so the number is negative
Leave 10 at the right alone and Complement the rest
11110110 00001010
the complement in decimal is 10
So the answer is -10
Two’s complement Applications
The two’s complement representation is the standard
representation used for storing integers by computers
today because it makes the operations simple.
SUMMARY OF INTEGER
REPRESENTATION
•Unsigned
•Sign & magnitude
•One’s complement
•Two’s complement
Contents of Sign & One’s Two’s
Unsigned
Memory magnitude complement complement
0000 0 +0 +0 +0
0001 1 +1 +1 +1
0010 2 +2 +2 +2
0011 3 +3 +3 +3
0100 4 +4 +4 +4
0101 5 +5 +5 +5
0110 6 +6 +6 +6
0111 7 +7 +7 +7
1000 8 -0 -7 -8
1001 9 -1 -6 -7
1010 10 -2 -5 -6
1011 11 -3 -4 -5
1100 12 -4 -3 -4
1101 13 -5 -2 -3
1110 14 -6 -1 -2
1111 15 -7 -0 -1
EXCESS SYSTEM
Excess System
‰
It's another representation that allows you to store both
positive and negative numbers in a computer
the
‰ magic number a positive number
used in the conversion process
‰ = N OR N
Answer:
= N OR N
= 8 OR 8
= OR
EXCESS_127 EXCESS_128
Excess System Representation
To represent a number in Excess, use the following
procedure:
‰Add the magic number to the integer
‰Change the result to binary and add 0s so that
there is a total of N bits
Excess System Representation
Example:
Represent –25 in Excess_127 using an 8-bit
allocation.
Answer:
127 + (-25) = 102
102
add 0’s to the left to make it 8 bit
01100110
Excess System Interpretation
To interpret a number in Excess, use the following
procedure:
‰
Change the number to decimal
Subtract the magic number from the integer
Excess System Interpretation
Example:
Interpret 11111110 if the representation is
Excess_127.
Answer:
11111110
254 – 127 = 127
FLOATING POINT
REPRESENTATION
Floating point representation
Example: 14.234
Integer Fraction
Convert from Floating point number to
binary
1. Convert the integer part to binary
2. Convert the fraction to binary
‰
3. Put a decimal point between the two parts
‰
Convert from Floating point number to
binary
Example
Transform the fraction 0.875 to binary
Answer:
Write the fraction at the left corner.
Multiply the number continuously by 2 and extract the
integer part as the binary digit. Stop when the
number is 0.0.
fraction 0.875 1.750 1.50 1.0 0.0
binary 0. 1 1 1
Convert from Floating point number to
binary
Example
Transform the fraction 0.4 to a binary of 6 bits.
Answer:
Write the fraction at the left cornet.
Multiply the number continuously by 2 and extract the integer part as
the binary digit.
You can never get the exact binary representation. Stop when
you have 6 bits
binary 0. 0 1 1 0 0 1
NORMALIZATION
Normalization
A fraction is normalized so that operations are
simpler
Normalization:
the moving of the decimal point so that there is
only one 1 to the left of the decimal point.
Normalization
Example:
+ 26 x 1.0001110101
ANSWER:
1 01111100 11001100000000000000000
ANSWER:
The sign is negative.
The exponent is –3 (124 –127).
The number after normalization is
-2-3 x 1.110011