0% found this document useful (0 votes)
13 views19 pages

Binary Arithemetic

The document explains binary arithmetic, focusing on (r-1)'s and r's complements, their applications in binary and octal systems, and the differences between 1's and 2's complements. It also covers binary addition, subtraction, multiplication, and division, detailing how to perform these operations using binary numbers. Additionally, it highlights the significance of two's complement for representing negative numbers and managing arithmetic operations effectively.

Uploaded by

mk.gupta.1189
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views19 pages

Binary Arithemetic

The document explains binary arithmetic, focusing on (r-1)'s and r's complements, their applications in binary and octal systems, and the differences between 1's and 2's complements. It also covers binary addition, subtraction, multiplication, and division, detailing how to perform these operations using binary numbers. Additionally, it highlights the significance of two's complement for representing negative numbers and managing arithmetic operations effectively.

Uploaded by

mk.gupta.1189
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

BINARY ARITHMETIC

(r-1)'s Complement of Numbers


 (r-1)'s complement of a number in any number system with a base
r can be obtained by subtracting every digit of a number from r-1.
◦ Example –
 In binary system, its (r-1)'s i.e., (2-1 =1's complement can be
obtained by subtracting every bit from 1, i.e., (111-001) = (110)2 is
the 1's complement of 001.
 The 1’s complement of 1011000 is 0100111
 The 1’s complement of 0101101 is 1010010
 In octal system, (777 – 347) = (430)8 is the 7's complement of 347.
 The 9’s complement of 546700 is 999999 – 546700 = 453299
 The 9’s complement of 012398 is 999999 – 012398 = 987601
r's Complement of Numbers
◦ The r's complement of a non-zero number in any number system with
base r can be obtained by adding 1 to the LSB of its (r-1)'s
complement.
◦Example –
 In binary system, 2's complement of 001 can be obtained by adding 1
to the LSB of its 1'complement, i.e., 110 + 1 = (111)2.
 2’s complement of binary 101100 = 010100.
 In octal system, 8's complement of 347 can be calculated by adding 1
to the LSB of its 7'complement, i.e., 430 + 1= (431)8.
 10’s complement of decimal 2389 = 7611.
 10’s complement of decimal 012389 = 987602.
 10’s complement of decimal 246700 = 753300.
Differences between 1’s complement and 2’s complement

1’s complement 2’s complement


To get 1’s complement of a binary number, To get 2’s complement of a binary number,
simply invert the given number. add 1 to the LSB of1’s complement.
1’s complement of binary number 110010 2’s complement of binary number 110010
is 001101 is 001110
Simple implementation which uses only Uses NOT gate along with full adder for
NOT gates for each input bit. each input bit.
Can be used for signed binary number
Can be used for signed binary number
representation and most suitable as
representation but not suitable as
unambiguous representation for all
ambiguous representation for number 0.
numbers.
For k bits register, positive largest number
For k bits register, positive largest number
that can be stored is (2(k-1)-1) and negative
that can be stored is (2(k-1)-1) and negative
lowest number that can be stored is -(2 -(k-1)
lowest number that can be stored is -(2(k-1)).
1).
2’s complement arithmetic operations are
1’s complement arithmetic operations are
easier than 1’s complement because of
not easier than 2’s complement because of
there is no addition of end-around-carry-
addition of end-around-carry-bit.
bit.
Binary Addition
◦ How to compute arithmetic in binary?
◦ Addition follows the same way irrespective of the base.
◦ Add the digits in each position and propagate the carry (if any).
◦ If signs are same, then add two magnitudes and give the sum with the common sign.
◦ If the signs are different, then subtract the smaller magnitudes from the larger and give
the result with the sign of the larger magnitude.
+6 00000110
◦ Example – -6 11111010
+13 00010011 00001101 00000111
+6 00000110
+13 00001101 -6
11111010
-13 11110011 -13
11110011 11111001
11101101
◦ Negative numbers must be in 2’s complement and that the sum obtained after the
addition if negative is in 2’s-complement form.
◦ Binary addition requires
 Add of two bits PLUS carry-in
 Also, carry-out if necessary
Sign/Magnitude Representation
◦ 1 bit for sign (0=positive, 1=negative)
◦ N-1 bits for magnitude
◦ Problem?
◦ Two zero’s: +0 different than - 0
◦ For a same zero (0), there are two different one’s complement
representation.

◦ To represent any negative number, 2’s complement method is used.


Two’s Complement Facts
◦ Signed two’s complement
◦ Negative numbers have leading 1’s
◦ zero is unique: +0 = - 0
◦ wraps from largest positive to largest negative
◦ N bits can be used to represent
◦ unsigned: range 0…….-1
◦ eg: 8 bits => 0…….255
◦ signed (two’s complement): -()……..( - 1)
◦ ex: 8 bits => (1000 0000) ………. (0111 1111)
◦ -128 …….. 127
Two’s Complement Addition
◦ Perform addition as usual, regardless of sign
◦ Examples
 1 + -1 =
 -3 + -1 =
 -7 + 3 =
 7 + (-3) =

◦ 1 + -1 = 0001 + 1111 = 0000 (0)


◦ -3 + -1 = 1101 + 1111 = 1100 (-4)
◦ -7 + 3 = 1001 + 0011 = 1100 (-4)
◦ 7 + (-3) = 0111 + 1101 = 0100 (4)
Binary Subtraction
◦ In binary subtraction is same as in any other bases

Minuend 10110
Subtrahend - 10010
Difference 00100

◦ When a borrow is needed. Note that the borrow gives us 2 in the


current bit position.
Binary Subtraction Contd…

◦ When there is no borrow into the MSB position, then the subtrahend in not
larger than the minuend and the result is positive and correct.
Binary Subtraction Contd…
◦ If a borrow into the MSB does occur, then the subtrahend is larger than the
minuend.
◦ Now do the operation 4 – 6

◦ Correct difference is -2 or -0010 and getting the is complicated.


Binary Subtraction Contd…
◦ But how do you represent a minus sign electronically in a computer?
◦ How can you represent it such that arithmetic operations are
manageable?
◦ There are two types of compliments for each number base system.
 Have the r’s complement
 Have the (r-1)’s complement
◦ For binary system have 2’s complement and 1’s complement.
◦ Add: 4 and -6
◦ Will use the 2’s complement of -6 or 1010
4 0100
-6 1010
1110
◦ And taking the 2’s complement of 1110 get 0001 + 1 = 0010
Binary Multiplication

◦ What is Binary Multiplication?


◦ The binary multiplication operation is actually a process of addition and shifting
operation. This process has to be continued until all the multiplier is done, and
finally, the addition operation is made.

◦ The multiplication rules for binary numbers is given below.


Binary
Multiplication Value
Number
0x0 0
1x0 0
0x1 0
1x1 1
◦ Example 1: Solve 1010 × 101
◦ Solution:
◦ 1010 × 101
◦ Comparison with Decimal
◦ 1010 values:
◦ (×) 101 ◦ 10102 = 1010
◦ —————– ◦ 1012 = 510
1010
◦ 10 x 5 = 5010
0000×
◦ (110010)2 = 5010
——————
01010 ……. First Intermediate Sum
1010××
——————–
110010
Question: 1011.01 × 110.1
Solution:
Binary Division
◦ The binary division operation is similar to the base 10 decimal system, except
the base 2. The division is probably one of the most challenging operations of the
basic arithmetic operations. There are different ways to solve division problems
using binary operations. Long division is one of them and the easiest and the
most efficient way.

◦ Binary Division Rules


◦ The binary division is much easier than the decimal division when you remember
the following division rules. The main rules of the binary division include:
◦ 1÷1 = 1
◦ 1÷0 = Meaningless
◦ 0÷1 = 0
◦ 0÷0 = Meaningless
◦ Example 1.
◦ Question: Solve 01111100 ÷ 0010
◦ Solution:
◦ Given
◦ 01111100 ÷ 0010
◦ Here the dividend is 01111100, and the divisor is 0010
◦ Remove the zero’s in the Most Significant Bit in both the dividend and divisor, that doesn’t change
the value of the number.
◦ So the dividend becomes 1111100, and the divisor becomes 10.
◦ Now, use the long division method.
◦ Step 1: First, look at the first two numbers in the dividend and compare with the divisor. Add the
number 1 in the quotient place. Then subtract the value, you get 1 as remainder.
◦ Step 2: Then bring down the next number from the dividend portion and do the step 1 process again
◦ Step 3: Repeat the process until the remainder becomes zero by comparing the dividend and the
divisor value.
◦ Step 4: Now, in this case, after you get the remainder value as 0, you have zero left in the dividend
portion, so bring that zero to the quotient portion.
◦ Therefore, the resultant value is quotient value which is equal to 111110
◦ So, 01111100 ÷ 0010 = 111110
◦Example 2: Solve using the long division method: 101101 ÷ 101

You might also like