Professional Documents
Culture Documents
1
Number Systems Conversions
Mixed Numbers
2
Number Systems Conversions
Mixed Numbers
0.812510 = ???2
3
Number Systems Conversions
Mixed Numbers
0.361510 = ???2
4
Number Systems Conversions
Mixed Numbers
13.2510 = ???2
It is convenient to
carry out separate
conversions for the
integer and fractional
parts.
5
Number Systems Conversions
Mixed Numbers
2 X 81 + 5 X 80 + 3 X 8-1 + 2 X 8-2
16 + 5 + 3 X 1/8 + 2 X 1/64 = 16+5+0.375+0.03125=21.4062510
6
Number Systems Conversions
Mixed Numbers
7
Unsigned and Signed Binary Numbers
Unsigned Binary Numbers
8
Unsigned and Signed Binary Numbers
Signed Binary Numbers
9
Signed Binary Numbers
Sign-magnitude approach
In sign-magnitude
representation, the most
significant bit of the given n-bit
binary number holds the sign,
and the remaining n - 1 bits
directly give the magnitude of
the negative number.
For example, the sign-magnitude
representation of +7 is 01 11 and
that of -4 is 1100.
Table 2.2 represents all possible
4-bit patterns and their meanings
in sign-magnitude form.
10
Signed Binary Numbers
Ones complement approach
In the complement approach, positive numbers have the same
representation as they do in the sign-magnitude representation. However,
in this technique negative numbers are represented in a different manner.
Before we proceed, let us define the term complement of a number. The
complement of a number A , written as Ā (or A’) is obtained by taking
bit-by-bit complement of A . In other words, each 0 in A is replaced with
1 and vice versa.
For example, the complement of the number 0100, is 1011 and that of 11
11 is 0000.
11
Signed Binary Numbers
Ones complement approach
In the ones complement approach,
a negative number, -x, is the
complement of its positive
representation.
For example let us find the ones
complement representation of
01002 (+410). The complement of
0100 is 1011, and this denotes the
negative number -410. Table 2.3
summarizes all possible 4-bit
binary patterns and their
interpretations as ones
complement numbers.
12
Signed Binary Numbers
Twos complement approach
Now, let us discuss the two’s complement approach. In this method,
positive integers are represented in the same manner as they are in the
sign-magnitude method. In other words, if the sign bit is zero, the number
is positive and its magnitude can be directly obtained by looking at the
remaining n - 1 bits.
However, a negative number -x can be represented in twos complement
form as follows:
1. Represent +x in sign magnitude form and call this result y
2. Take the ones complement of y to get y’
3. y’ + 1 is the twos complement representation of -x.
13
Binary Addition Rules
14
Signed Binary Numbers
Twos complement approach - EXAMPLES
15
Signed Binary Numbers
Twos complement approach – More
EXAMPLES
16
Signed Binary
Numbers
Twos
complement
approach
17
Comparison of Number Systems
18
Addition and Subtraction in Binary Numbers
Unsigned
19
Addition and Subtraction in Binary Numbers
Unsigned - Overflow
Digital systems usually operate on a fixed number of digits. Addition is
said to overflow if the result is too big to fit in the available digits.
A 4-bit number, for example, has the range [0, 15]. 4-bit binary addition
overflows if the result exceeds 15. The fifth bit is discarded, producing
an incorrect result in the remaining four bits. Overflow can be detected
by checking for a carry out of the most significant column.
20
Overflow!!!
21
Addition and Subtraction in Binary Numbers
2’s Complement
The addition and subtraction are carried as with unsigned numbers except
for the handling of the carry.
The computer automatically sets an overflow bit to 1 if the result of an
arithmetic operation is too big for the computer's maximum word size;
otherwise it is reset to 0.
22
Addition and Subtraction in Binary Numbers
2’s Complement
23
Addition and Subtraction in Binary Numbers
2’s Complement - Overflow
Adding two N-bit positive numbers or negative numbers may cause
overflow if the result is greater than 2N−1 −1 or less than −2N−1.
Adding a positive number to a negative number never causes overflow.
24
Addition and Subtraction in Binary Numbers
2’s Complement - Overflow
25
Addition and Subtraction in Binary Numbers
2’s Complement - Overflow
Consider the examples for 8-bit numbers:
Let C7 be the carry out of the most significant bit (sign bit) and C6 be
the carry out of the previous (bit 6) data bit (seventh bit).
When C7 and C6 are the same, the result is always correct, and the
carry is ignored.
If C7 and C6 are different, the result is incorrect and sets the overflow
bit to 1
26
Addition and Subtraction in Binary Numbers
2’s Complement - Overflow
Case 1: C7 and C6 are the same.
27
Addition and Subtraction in Binary Numbers
2’s Complement - Overflow
Case 2: C7 and C6 are different.
28
Example (1/3)
Perform the following signed operations and comment on the
results. Assume twos complement numbers.
(a) A = 10102, B = 01002. Find A - B.
(b) Perform ( -310) - (-210) using twos complement and 4 bits.
29
Example (2/3)
(a) If we increase the number of bits for A and B to 5, the correct
result can be obtained as follows:
30
Example (3/3)
31