BCA - Arithmetic Operations of Binary Numbers
BCA - Arithmetic Operations of Binary Numbers
Binary Addition:
Binary addition is performed in the same way as addition in the decimal-
system and is, in fact, much easier to master. Binary addition obeys the following
four basic rules:
0 0 1 1
+0 +1 +0 +1
0 1 1 10
The results of the last rule may seem some what strange, remember that these are
binary numbers. Put into words, the last rule states that
binary one + binary one = binary two = binary "one zero"
When adding more than single-digit binary number, carry into, higher order
columns as is done when adding decimal numbers. For example 11 and 10 are
added as follows:
11
+ 10
101
In the first column (L S C or 2°) '1 plus 0 equal 1. In the second column (2 1)
1 plus 1 equals 0 with a carry of 1 into the third column (2 2).
When we add 1 + 1.+ 1 (carry) produces 11, recorded as 1 with a carry to the
next column.
Example 12: Add (a) 111 and 101 (b) 1010, 1001 and 1101.
Solution:
(a) (1) (1)
111
101
1100
(B) (2)(1)(1)(1)
1010
1001
1101
10000
Binary Subtraction:
Binary subtraction is just as simple as addition subtraction of one bit from
another obey the following four basic rules
0–0=0
1 – 1 =0
1–0=1
10 – 1 = 1 with a transfer (borrow) of 1.
When doing subtracting, it is sometimes necessary to borrow from the next
higher-order column. The only it will be necessary to borrow is when we try to
subtract a 1 from a 0. In this case a 1 is borrowed from the next higher-order
column, which leaves a 0 in that column and creates a 10 i.e., 2 in the column
being subtracted. The following examples illustrate binary subtraction.
Multiplication of fractional number is performed in the same way as with fractional numbers
in the decimal numbers.
Solution:
(a)
10 (b) 100
11 110 11 11000
11 11
00 00
00 0 0_
00 00
00
00
Binary division problems with remainders are also treated the same as in the
decimal system, as illustrates the following example.
Example 18: Perform the following binary division:
(a) 1111 ÷ 110 (b) 1100 ÷ 101
Solution: (a) 10. 1 (b) 10. 011
110 1 111.00 110 100.00
1 10 1 01
1 10 100
1 10 000
000 1000
101
110
101
1
(reminder)
Two's Complement Addition
Add the values and discard any carry-out bit.
Examples: using 8-bit two’s complement numbers.
1. Add −8 to +3
2. (+3) 0000 0011
3. +(−8) 1111 1000
4. -----------------
5. (−5) 1111 1011
6. Add −5 to −2
7. (−2) 1111 1110
8. +(−5) 1111 1011
9. -----------------
10. (−7) 1 1111 1001 : discard carry-out
Overflow occurs if
(+A) + (+B) = −C
(−A) + (−B) = +C
EBCDIC CODE:
Extended Binary Coded Decimal Interchange Code- In this code it is
possible to represent 256 (2⁸). It also allows a large variety of printable characters
& non printable control characters.
EBCDIC can be easily divided into 2 4 bit groups. Each of these 4 bit groups
can be represented by 1 hexa digit. Thus Hexadecimal Number system is used as a
shortcut notation for memory dump by computers that use EBCDIC for internal
representation of characters.
Two types of formats :
1. Zoned Decimal Format
2. Packed Decimal Format.
When a numeric value is represented in EBCDIC, to represent whether
number is positive, negative or unsigned sign indicator is used in the zone position
of the rightmost digit.
Printers print only those numeric charaters that are in a Zoned Decimal
Format so this format is useful while printing the Data.
Most computers cannot perform arithmetic operations on Zoned Decimal
Data. To perform arithmetic calculation it had to be converted to Packed Decimal
Format.
ASCII:
American Standard Code for Information Interchange - It is accepted by
several computer manufacturers as their computer’s internal code. This code is
popular in data communications, is used almost exclusively to represent data
internally in micro-computers.
ASCII is of two types:-
ASCII – 7 7 bit code 2⁷ = 128
ASCII – 8 8 bit code 2⁸ = 256
Additional bit is added to the Zone bit.