Binary Arithmetic:
Binary addition, Binary subtraction, Negative number representation,
Subtraction using 1’s complement and 2’s complement, Binary
multiplication and division, Arithmetic in octal number system,
Arithmetic in hexadecimal number system, BCD and Excess – 3
arithmetic.
2. UNIT I: CONTENTS
Number System:
Analog System, digital system,
Numbering system, binary number system, octal number system, hexadecimal number system, conversion from one number
system to another, floating point numbers,
Weighted codes binary coded decimal, non-weighted codes Excess – 3 code, Gray code,
Alphanumeric codes – ASCII Code, EBCDIC, ISCII Code, Hollerith Code, Morse Code,Teletypewriter (TTY), Error
detection and correction, Universal Product Code,
Code conversion.
Binary Arithmetic:
Binary addition, Binary subtraction,
Negative number representation,
Subtraction using 1’s complement and 2’s complement, Binary multiplication and division,Arithmetic in octal number system,
Arithmetic in hexadecimal number system,
BCD and Excess – 3 arithmetic.
C
H
A
P
T
E
R
I
C
H
A
P
T
E
R
II
3. BINARY ADDITION
Binary arithmetic is essential part of all the digital
computers and many other digital system.
Binary Addition is a key for binary subtraction,
multiplication,division.There are four rules of binary
addition.
In fourth case,
a binary addition is creating a sum of (1 + 1 = 10)
i.e. 0 is written in the given column and a carry of 1
over to the next column.
Example − Addition
4. BINARY SUBTRACTION
Subtraction and Borrow, these two words
will be used very frequently for the binary
subtraction.There are four rules of binary
subtraction.
Example − Subtraction
5. BINARY MULTIPLICATION
Binary multiplication is similar to decimal
multiplication.It is simpler than decimal
multiplication because only 0s and 1s are involved.
There are four rules of binary multiplication.
Example − Multiplication
6. BINARY DIVISION
Binary division is similar to decimal division. It is
called as the long division procedure.
Example − Division
7. NEGATIVE NUMBER REPRESENTATION
Negative numbers can be distinguishable with the help of extra bit or flag called sign bit or sign flag in Binary
number representation system for signed numbers.
It is not possible to add minus or plus symbol in front of a binary number because a binary number can have only
two symbol either 0 or 1 for each position or bit.
That’s why we use this extra bit called sign bit or sign flag.The value of sign bit is 1 for negative binary numbers
and 0 for positive numbers.
There are three possible ways:
Sign-Magnitude method,
1’s Complement method,and
2’s complement method.
8. SIGNED MAGNITUDE METHOD
In this method, number is divided into two parts: Sign
bit and Magnitude. If the number is positive then sign
bit will be 0 and if number is negative then sign bit will
be 1. Magnitude is represented with the binary form
of the number to be represented.
Example:Let we are using 5 bits register.The
representation of -5 to +5 will be as follows:
Range of Numbers: For k bits register, MSB will be
sign bit and (k-1) bits will be magnitude. Positive largest
number that can be stored is (2(k-1)-1) and negative
lowest number that can be stored is -(2(k-1)-1).
Note that drawback of this system is that 0 has two
different representation one is -0 (e.g., 1 0000 in five bit
register) and second is +0 (e.g., 0 0000 in five bit
register).
9. 1’S COMPLEMENT METHOD
Positive numbers are represented in the same way as
they are represented in sign magnitude method. If the
number is negative then it is represented using 1’s
complement.First represent the number with positive
sign and then take 1’s complement of that number.
Example:Let we are using 5 bits register.The
representation of -5 and +5 will be as follows:
+5 is represented as it is represented in sign magnitude method.-5
is represented using the following steps:
(i) +5 = 0 0101
(ii)Take 1’s complement of 0 0101 and that is 1 1010.MSB is 1
which indicates that number is negative.
MSB is always 1 in case of negative numbers.
Range of Numbers:For k bits register,positive largest number
that can be stored is (2(k-1)-1) and negative lowest number that can
be stored is -(2(k-1)-1).
Note that drawback of this system is that 0 has two different
representation one is -0 (e.g.,1 1111 in five bit register) and
second is +0 (e.g.,0 0000 in five bit register).
10. 2’S COMPLEMENT METHOD
2’s Complement Method: Positive numbers are represented
in the same way as they are represented in sign magnitude
method. If the number is negative then it is represented using 2’s
complement. First represent the number with positive sign and
then take 2’s complement of that number.
Example: Let we are using 5 bits registers.The representation of
-5 and +5 will be as follows:
+5 is represented as it is represented in sign magnitude method. -5 is
represented using the following steps:
(i) +5 = 0 0101
(ii)Take 2’s complement of 0 0101 and that is 1 1011.MSB is 1
which indicates that number is negative.
MSB is always 1 in case of negative numbers.
Range of Numbers: For k bits register, positive
largest number that can be stored is (2(k-1)-1) and
negative lowest number that can be stored is -(2(k-1)).
The advantage of this system is that 0 has only one
representation for -0 and +0. Zero (0) is considered
as always positive (sign bit is 0) in 2’s complement
representation.Therefore,it is unique or unambiguous
representation.
2’s Complement
Step 1:Write the absolute value of the given number in
binary form. Prefix this number with 0 indicate that it is
positive.
Step 2:Take the complement of each bit by changing
zeroes to ones and ones to zero.
Step 3:Add 1 to your result.
11. SUBTRACTION USING 1’S COMPLEMENT
The steps to be followed in subtraction by
1’s complement are:
i)To write down 1’s complement of the
subtrahend.
ii)To add this with the minuend.
iii) If the result of addition has a carry over
then it is dropped and an 1 is added in the last
bit.
iv) If there is no carry over, then 1’s
complement of the result of addition is
obtained to get the final result and it is
negative.
Evaluate: (i) 110101 – 100101
Solution:
1’s complement of 10011 is 011010. Hence
Minued - 1 1 0 1 0 1
1’s complement of subtrahend - +0 1 1 0 1 0
_________
Carry over - 1 0 0 1 1 1 1
Add 1Becouse carry is 1 + 1
Final Result - 0 1 0 0 0 0
The required difference is 10000
12. SUBTRACTION USING 1’S COMPLEMENT: EXAMPLES
1’s complement of 111001 is 000110. Hence
Minued - 1 0 1 0 1 1
1’s complement of subtrahend - + 0 0 0 1 1 0
No Carry over - 1 1 0 0 0 1
Take complement of addition 0 0 1 1 1 0
Final Result - - 1 1 1 0
(ii) 101011 – 111001 (iii) 1011.001 – 110.10
1’s complement of 0110.100 is 1001.011 Hence
Minued - 1 0 1 1 . 0 0 1
1’s complement of subtrahend - + 1 0 0 1 . 0 1 1
Carry over - 1 0 1 0 0 . 1 0 0
Add 1Becouse carry is 1 + 1
Final Result - 0 1 0 0 . 1 0 1
(iv) 10110.01 – 11010.10
1’s complement of 11010.10 is 00101.01
Minued - 1 0 1 1 0 . 0 1
1’s complement of subtrahend - + 0 0 1 0 1 . 0 1
No Carry over - 1 1 0 1 1 . 1 0
Final Result - – 100.01
Rules:
1. To write down 1’s complement of the subtrahend.
2. To add this with the minuend.
3. If the result of addition has a carry over then it is
dropped and an 1 is added in the last bit.
4. If there is no carry over, then 1’s complement of
the result of addition is obtained to get the final
result and it is negative.
13. SUBTRACTION USING 2’S COMPLEMENT
The operation is carried out by
means of the following steps:
(i) At first, 2’s complement of the
subtrahend is found.
(ii) Then it is added to the minuend.
(iii) If the final carry over of the sum
is 1, it is dropped and the result is
positive.
(iv) If there is no carry over, the
two’s complement of the sum will be
the result and it is negative.
14. SUBTRACTION USING 2’S COMPLEMENT: EXAMPLES
Rules:
1. At first, 2’s complement of the
subtrahend is found.
2. Then it is added to the minuend.
3. If the final carry over of the sum is 1,
it is dropped and the result is
positive.
4. If there is no carry over, the two’s
complement of the sum will be the
result and it is negative.
15. SUBTRACTION USING 2’S COMPLEMENT: EXAMPLES
Rules:
1. At first, 2’s complement of the
subtrahend is found.
2. Then it is added to the minuend.
3. If the final carry over of the sum is 1,
it is dropped and the result is
positive.
4. If there is no carry over, the two’s
complement of the sum will be the
result and it is negative.
16. SUBTRACTION USING 2’S COMPLEMENT: EXAMPLES
Rules:
1. At first, 2’s complement of the
subtrahend is found.
2. Then it is added to the minuend.
3. If the final carry over of the sum is 1,
it is dropped and the result is
positive.
4. If there is no carry over, the two’s
complement of the sum will be the
result and it is negative.
18. ARITHMETIC IN OCTAL NUMBER SYSTEM: OCTAL ADDITION
Following are the
characteristics of an octal
number system:
Uses eight digits, 0,1,2,3,4,5,6,7.
Also called base 8 number
system.
Each position in an octal
number represents a 0 power
of the base (8). Example: 80
Last position in an octal
number represents an x power
of the base (8). Example: 8x
where x represents the last
position - 1.
Following octal addition table will help you to handle octal addition.
To use this table, simply
follow the directions used in
this example:
Add 68 and 58.
Locate 6 in the A column
then locate the 5 in the B
column.
The point in 'sum' area
where these two columns
intersect is the 'sum' of
two numbers.
68 + 58 = 138.
20. ARITHMETIC IN OCTAL NUMBER SYSTEM: OCTAL SUBTRACTION
The subtraction of octal numbers follows the same rules as the subtraction of numbers in any other number
system.The only variation is in borrowed number. In the decimal system, you borrow a group of 1010. In the
binary system, you borrow a group of 210. In the octal system you borrow a group of 810.
21. ARITHMETIC IN HEXADECIMAL NUMBER SYSTEM:ADDITION
Following are the characteristics
of a hexadecimal number system.
Uses 10 digits and 6 letters,
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.
Letters represents numbers
starting from 10.A = 10,B = 11, C
= 12, D = 13, E = 14, F = 15.
Also called base 16 number
system.
Each position in a hexadecimal
number represents a 0 power of
the base (16).Example − 160
Last position in a hexadecimal
number represents an x power of
the base (16).Example − 16x
where x represents the last
position - 1.
Following Hexadecimal addition table will help you
greatly to handle Hexadecimal addition.
To use this table, simply
follow the directions used
in this example −
Add A16 and 516.
Locate A in the X
column then locate the
5 in theY column.
The point in 'sum' area
where these two
columns intersect is
the sum of two
numbers.
A16 + 516 = F16.
23. ARITHMETIC IN HEXADECIMAL NUMBER SYSTEM: SUBTRACTION
The subtraction of hexadecimal numbers follow
the same rules as the subtraction of numbers in
any other number system.
The only variation is in borrowed number.
In the decimal system, you borrow a group of
1010. In the binary system, you borrow a group of
210. In the hexadecimal system you borrow a
group of 1610.
3F57A – C85E = 32D1C
24. BCD AND EXCESS – 3 ARITHMETIC
Excess 3 code is a basically a binary code which is made by adding 3 with the equivalent decimal of a binary
number and again converting it into binary number.
BCD addition and subtraction can be done by this method.
Step 1:We have to convert the BCD numbers (which are to be added) into excess 3 forms by adding 0011
with each of the four bit groups them or simply increasing them by 3.
Step 2: Now the two numbers are added using the basic laws of binary addition, there is no exception for
this method.
Step 3: Now which of the four groups have produced a carry we have to add 0011 with them and subtract
0011 from the groups which have not produced a carry during the addition.
Step 4:The result which we have obtained after this operation is in Excess 3 form and this is our desired
result.
25. BCD ADDITION USING EXCESS 3 CODE
Example: BCD numbers 356 & 579 to be added
using excess 3 code.
Step 1: Convert each number into excess code by
adding 0011 to each subgroup.
356 → 0011 0101 0110Adding 0011,
Excess3 number of 356 is 0110 1000 1001
579 → 0101 0111 1001Add 0011,
Excess 3 number of 579 is 1000 1010 1100.
Step 2: Simply do binary addition.
Carry is produced in second & third subgroups.
Step 3: Add 0011 when there is carry. Subtract 0011 when there is no
carry.
Considering third group where there is no carry.1111 - 0011=1100.
Considering other 2 sub groups
0011 + 0011= 0110
0101+0011= 1000.
Answer in excess3 is
1100 0110 1000.
Step 4:To convert it back to BCD form,subtract 0011 from each
subgroup & express in BCD.
1100–0011=1001 -> 9
0110–0011=0011 ->3
1000- 0011= 0101 -> 5
BCD answer is 935.
(Verify 356+ 579 = 935).
0110 1000 1001
+1000 1010 1100
______________
1111 0011 0101
26. BCD SUBTRACTION USING EXCESS 3 CODE
Step 1: convert both the number in
Excess-3 by adding 0011.
Step 2: Follow Normal Binary
subtraction.
Step 3: Subtract 0011 from each BCD 4-
bit binary group in the answer if the
subtraction operation of the relevant 4-
bit groups required a borrow from the
next higher adjacent 4-bit group.
Step 4:Add 0011 to the remaining 4-bit
groups, if any in the result.
Finally, we get the result on excess-3
code.
Convert back into BCD.
Example: 0001 1000 0101 – 0000 0000 0001
Solution:
Step 1: Convert above numbers in XS-3
0100 1011 1000 and 0011 0011 1011.
Step 2: Perform Binary Subtraction
0100 1011 1000
- 0011 0011 1011
_____________
0001 0111 1101
Step 3:The last 4-bit group needed a borrow so we
need to subtract 0011 from result of this group.And
other two 4-bit groups didn’t require borrow so we
need to add 0011 to each of them.
0001 + 0011= 0100
0111 + 0011= 1010
1101 – 0011= 1010
Step 4:To convert it back to BCD form,subtract 0011
from each subgroup & express in BCD.
SoThe result will be 0001 0111 0111