ITU07102.Lecture.5-Signed Number and BCD
ITU07102.Lecture.5-Signed Number and BCD
Solution:
• First, we write 710 in binary using 5 bits:
001112.
• Next, we change our sign bit from 0 to 1
to make the number negative: 101112.
Arithmetic issues with signed magnitude
While representing negative numbers with signed magnitude is simple,
performing arithmetic with signed magnitude is difficult. What we would really
like to have is a way of representing signed numbers that simplifies our binary
arithmetic.
Suppose we could represent signed numbers in such a way that all our
computations could be completed using only addition. This would allow our
computer processor to perform all arithmetic operations with only addition
circuitry.
It’s well known that multiplication is really repeated addition, so this is not a
problem.
Division and Subtraction. Division is just repeated subtraction. Now, how can
we convert our subtraction problems to addition?
For example: Consider the subtraction problem 3010 - 710.
• This problem can be converted into an equivalent addition
problem by changing 710 to -710.
• Next, we reverse each bit of the number so 1's become 0's and
0's become 1's 1010 (-5)
A quick summary of how to find the 1's complement
representation of any decimal number x.
b. 010112
c. 001112
d. 000012
Two’s Complement
Representing a signed number with 2's complement is done by
adding 1 to the 1's complement representation of the number.
To illustrate, let's look at the same example we used for 1's
complement.
How can we represent the number -510 in 2's complement using
4-bits?
Notice the first three steps are the same as 1's complement.
1. 1100002
2. 0011012
3. 1111012
4. 1101102
5. 0110102
6. 1000012
Subtraction with Signed Numbers
Using 1’s Complement in Subtraction
Summary of the steps for subtracting x from y with an n-bit 1's
complement representation.
1. Negate x using 1's complement.
Reverse all the bits in x to form -x.
2. Add -x and y.
3. If the sum exceeds n bits (overflowing bit), add the extra
bit (overflowing bit) to the result.
4. If the sum does not exceed n bits, leave the result as it is.
Solve each of the following 5-bit subtraction problems using 1's complement
representation.
a. 001102 – 001012
b. 011002 - 010102
c. 001002 - 001012
d. 010012 - 010112
e. 000112 - 011002
f. 001102 - 010012
For each part, the correct 1's complement representation of the subtrahend is
given first followed by the answer.
a. 110102; 000012
b. 101012; 000102
c. 110102; 111102
d. 101002; 111012
e. 100112; 101102
f. 101102; 111002
Using 2’s Complement in Subtraction
b. 011012 – 010012
c. 010002 – 000112
d. 011102 – 011002
For each part, the correct 2's complement representation of the subtrahend is
given first followed by the answer.
a. 110112; 000012
b. 101112; 001002
c. 111012; 001012
d. 101002; 000102
Binary Coded Decimals (BCD)
Binary Coded Decimals
When numbers, letters, or words are represented by a special a
special group of symbols, we say they are being coded, and the
group of symbols is called code.
In four bit system, we have seen that any decimal number (0-9)
can be represented by equivalent binary numbers (see table).
Note: The group of 0s and 1s in the binary number can be thought as
a code representing the decimal number.
Note: BCD only uses Four-bit binary numbers from 0000 through
1001BCD does not use the numbers 1010, 1011, 1100, 1101, 11101
and 1111 - these are called "Forbidden" four-bit patterns in BCD. If
it happened, means an error.
Example: Convert 0110100000111001 (BCD) to is decimal
equivalent.