0% found this document useful (0 votes)
39 views

w4 Binary Operations

Binary operations include addition, subtraction, multiplication, and division. Addition involves adding two binary numbers by combining bits and carrying over when needed. Subtraction can be done directly, using 1's complement, or using 2's complement by inverting and adding bits. Multiplication is done by multiplying each bit of one number by the other number. Division involves repeatedly subtracting the divisor from the dividend and shifting the remainder left until the remainder is zero.

Uploaded by

Abb
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

w4 Binary Operations

Binary operations include addition, subtraction, multiplication, and division. Addition involves adding two binary numbers by combining bits and carrying over when needed. Subtraction can be done directly, using 1's complement, or using 2's complement by inverting and adding bits. Multiplication is done by multiplying each bit of one number by the other number. Division involves repeatedly subtracting the divisor from the dividend and shifting the remainder left until the remainder is zero.

Uploaded by

Abb
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

BINARY OPERATIONS

• Addition
• Subtraction
• Multiplication
• Division

• Addition
• Binary Addition
• It involves adding two binary numbers A B Addition

• Example: adding a single bit


0 0 0
0 1 1
1 0 1
1 1 0 Carry 1 = 1 0

• Example: adding a string of bits A= 1011101.1101+


B= 1110011.0111
1010001.0100
IST 2010 COP: Chapter 3: Binary Operations: Omae M. Oteri
Binary Subtraction
• Methods of Subtraction
• Direct Subtraction
• Subtraction using 1’s complements A B Addition
• Subtraction using 2’s complements 0 0 0
0 1 1 Borrow 1
• Direct Subtraction 1 0 1
1 1 0
• Example: subtracting a single bit
• Example 1: subtracting a string of bits A= 11001.101-
B= 10111.111
• Subtraction using complements 00001.110

• 1’s complement
• Procedure
• Invert the binary number i.e. invert all the bits individually
• Where there is 1 change it to 0 and vice versa
• 2’s complement 1’s Compliment
Example: 1 0 1 1 02 01001
• Procedure
• First obtain 1’s complement
• Add a 1 to the Least Significant Bit
• Example: 10110010 0 1 0 0 1 1 0 1 1’s Compliment
+ 1
1 0 0 1 1 1 0 2’s Compliment
IST 2010 COP: Chapter 3: Binary Operations: Omae M. Oteri
2nd method
• Procedure
• Take the binary and check for the first 1 from the LSB
• Arrange the binary bits the way they appear including the first bit
Example 1: 1 0 1 1 0 0 1 0
• Complement the rest 0 1 0 0 1 1 1 0 2’s Compliment

• Subtraction using 1’s Compliment Example 1:


A= 101101-
B= 100011
• Procedure 001010

• Compliment the subtrahend and add it to the minuend 1’s compliment for B = 0 1 1 1 0 0
A= 101101+
• If there is a carry take it round and add it to the LSB B’ = 0 1 1 1 0 0
1 0 0 1 0 0 1 + Result is a POSITIVE so add it
• The result will be correct and positive 001010
1

• If there is no carry the result is not


Example 2:
B= 100011-
A= 101101
correct and will be negative 001010

• Re-compliment and attach a negative 1’s compliment for A = 0 1 0 0 1 0

A’ = 010010+
B= 100011
0 1 1 0 1 1 1 + Result is a NEGATIVE so re-compliment
001000
IST 2010 COP: Chapter 3: Binary Operations: Omae M. Oteri
Subtraction using 2’s Complement
• Procedure
• Obtain the 2’s complement of the subtrahend
• Add it to the minuend
• If there is a carry discard it; the result is correct and positive
• If there is no carry; the result is negative and incorrect
• Re-complement it (using 2’s complement) and attaché a negative

Example 1:
A= 101101
B= 100011

B’ + 1 = 111101+
A = 101101
1 0 0 1 0 1 0 Discard the carry 1

Example 2:
B= 100011
A= 101101

A’ + 1 = 010011+
B = 100011
0 1 1 0 1 1 0 Result is a NEGATIVE so re-complement
001001
IST 2010 COP: Chapter 3: Binary Operations: Omae M. Oteri
Multiplication
• Example 1: Multiplying a single bit
A 1 1 0 1. 1 0 1
A B Result B 1 0 1 1. 1 1
0 0 0 1011 01
0 1 0 1011 01
1 0 0 1011 01
000000
1 1 1
1011 01
1 0 1 0 0 0 0 0. 0 0 0 1 1

• Example 2: Multiplying a string of bits


Dividend 1 1 1 . 1 1 x 100 = 11111
• Division Dividend
Divisor
20
5
10100
101
Divisor 0 .1 x 100 10

• Whole numbers/integers 100 1111.1


10√11111
101√10100
• Example
10
101 11
10
000
• Done by subtracting the divisor from the
11
10
11
10
dividend and shifting it to the left until the 10
10

remainder is 0 11 1.11 ≈ 1111.1


0.1

IST 2010 COP: Chapter 3: Binary Operations: Omae M. Oteri

You might also like