Binary-Arithmeticcccccccccccccccccc.pptx

DynamoFFofficial 18 views 51 slides Oct 03, 2024
Slide 1
Slide 1 of 51
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51

About This Presentation

This is the ppt for arithmetic operators in deco


Slide Content

Binary Arithmetic

Binary operations Binary addition Binary subtraction Binary multiplication Binary division

Binary addition Rules for binary addition:

Binary addition

Addition of large binary numbers

Solve (12) 10 + (8) 10 (15) 10 + (10) 10 (35) 10 + (48) 10 (10101) 2 + (10110) 2 (10111) 2 + (11000) 2

Binary Subtraction

Rules for binary subtraction

Binary subtraction

Subtraction of large binary numbers 11001 - 10111 = 00010

Examples

Binary subtraction Example 1:  0011010 – 001100 Solution: 1 1 Borrow 0 0 1 1 0 1 0 (-) 0 0 1 1 0 0 —————— 0 0 0 1 1 1 0 Decimal Equivalent : 0 0 1 1 0 1 0 = 26 0 0 1 1 0 0 = 12 Therefore, 26 – 12 = 14 The binary resultant 0 0 0 1 1 1 0 is equivalent to the 14

Logic for binary to decimal 0 0 1 1 0 1 0 =26 2 6 2 5 2 4 2 3 2 2 2 1 2 64 32 16 8 4 2 1 16 8 2 =26

Binary Subtraction Example 2:  0100010 – 0001010 Solution: 1 1 Borrow 0 1 0 0 0 1 0 = 34 10 (-) 0 0 0 1 0 1 0 = 10 10 —————— 0 0 1 1 0 0 0 = 24 10

Binary subtraction subtract 1010101.10 from 1111011.11 1 borrow 1111011.11 – 1010101.10 ——————– 0100110.01 ——————–

Binary subtraction using 1’s and 2’s complement method

How to find 1’s Complement of given number 1’s complement of a number is found by changing all 1’s to 0’s and all 0’s to 1’s. Ex: 1’s complement of a number 10111 is = 01000 Solve---- Find 1’s complement of 11010 = 00101 101101= 010010 1010= 0101 1111=0000 1011001=0100110

How to find 2’s Complement of given number The 2’s complement of a number is obtained by adding 1 to the LSB of 1’s complement of that number 2’s complement = 1’s complement + 1 Ex: obtain 2’s complement of a number (10110010) 2 Solution:

Solve Find 2’s complement of following numbers. (1101) 2 0010=1=0011 (10111) 2 01000+1=01001 (101101 )2 010010+1=010011 (1011111) 2 010000+1=010001 (101111101) 2 010000010+1=010000011

Subtraction using 1 s  complement     A) For subtracting a smaller number from a larger number, the 1 s  complement method is as follows: 1. Determine the 1 s  complement of the smaller number. 2. Add the 1 s  complement to the larger number. 3. Remove the final carry and add it to the result. This is called the end-around carry.

Binary subtraction using 1’s complement method To perform subtraction (A) 2 - (B) 2 Step 1: convert number to be subtracted (B) 2 to its 1’s complement. Step 2: Add first number (A) 2 and 1’s complement of (B) 2 using rules of binary addition. Step 3: if final carry is 1 then add it to the result of addition obtained in step 2 to get final result. **If final carry in step 2 is 1 then result obtained in step 2 is Positive and in its true form no conversion required. Step 4: if final carry in step 2 is 0 then result obtained in step 2 is negative and in 1’s complement form. So convert it to its true form.

Binary subtraction using 1’s complement 10---------------------------------- 10 -3 - 11-----1’complement of 11 +00 --- ----- -1 10 result 1’s complement of result 01 final result carry 0 so result sign is negative

3 11 11 -2 10---------01 ---------- 1 0 0 1 ------------ 01

Binary subtraction using 1’s complement 9 1001 1001 15 1111 1’s complement +0000 ------- ------- -6 1001 1’s complement of result 0110 ---6 carry is 0 so result sign is negative

Binary Subtraction Questions Using 1’s Complement Question 1: (110101) 2  – (100101) 2 Solution: (1 1 0 1 0 1) 2  = 53 10------- minuend. (1 0 0 1 0 1) 2  = 37 10  – subtrahend Now take the 1’s complement of the subtrahend and add with minuend. 1 carry 1 1 0 1 0 1 (+) 0 1 1 0 1 0 —————— 0 0 1 1 1 1 + 1 carry —————— 0 1 0 0 0 0 Therefore, the solution is 010000 (010000) 2  = 16 10 1

Binary Subtraction Questions Using 1’s Complement Question 2: (101011) 2  – (111001) 2 43-57= -14 Solution: Take 1’s complement of the subtrahend 1 1 1 1 0 1 0 1 1 (+) 0 0 0 1 1 0 (1’s complement) —————— 1 1 0 0 0 1 Now take the 1’s complement of the resultant since it does not carry 1 The resultant becomes 0 0 1 1 1 0 Now, add the negative sign to the resultant value Therefore the solution is – (001110) 2 .

Binary subtraction using 2’s complement method To perform subtraction (A) 2 - (B) 2 Step 1: convert number to be subtracted (B) 2 to its 2’s complement. Step 2: Add first number (A) 2 and 2’s complement of (B) 2 using rules of binary addition. Step 3: if final carry is 1 then the result Positive and in its true form no conversion required. Step 4: if final carry in step 2 is 0 then result obtained in step 2 is negative and in 2’s complement form. So convert it to its true form. ** Carry always be discarded.

Binary subtraction using 2’s complement 5 101 -7 111 1’s comple .---000 ---- + 1 -2 ------ 2’s complement 001 +101 ------- result 110 1’s complement 001 + 1 -------- 2’s complement 010 final result Carry is 0 so result is negative

13 1101 -10 1010 0101 ------- 1 03 --------- 0110 1101 -------------- 1 0011

Subtraction using 2’s complement 33 100001 -45 101101 1’s 010010 ----- + 1 -12 ------------ 2’s 010011 +100001 ------------ 110100 result 1’s 001011 + 1 ------------- 2’s 001100 final result

Solve the following binary subtraction using 1’s and 2’s complement method 15-23 25-18 23-18 18-9

10111 10111 -10010 01101 1’s 1 --------- 01110 10111 ----------- 100101

Binary Multiplication

Multiplication (1 of 3) Decimal (just for fun) 35 x 105 175 000 35 3675

Multiplication Binary, two 1-bit values A B A  B 1 1 1 1 1

Example Binary Multiplication A = 9 10 = 1001 2 A 3 A 2 A 1 A B = 8 10 = 1000 2 B 3 B 2 B 1 B   1001 × 1000 ------------------ 0000 multiply by B + 0000 multiply by B 1 + 0000 multiply by B 2 + 1001 multiply by B 3 -------------- 1001000 Cross check 1 0 0 1 0 0 0 64 32 16 8 4 2 1 place value of result bits 64+8=72

Perform the following multiplication in binary number system : 1011 2 × 101 2 1 0 1 1 × 1 0 1 --------- 1 0 1 1 + 0 0 0 0 + 1 0 1 1 carry 1 ------------------- 1 1 0 1 1 1

Perform the following multiplication in binary number system: 101.1 2 × 11.1 2 1 0 1 .1 × 1 1 .1 ---------------- 1 0 1 1 + 1 0 1 1 + 1 0 1 1 Carry 1 1 1 1 --------------------- 1 0 0 1 1. 0 1

Multiplication Binary, two n -bit values As with decimal values E.g., 1110 x 1011 1110 1110 0000 1110 10011010

Binary Multiplication Perform the following multiplication in binary number system: 15 10 × 8 10 Perform the following multiplication in binary number system: 1001 2 × 1101 2 Perform the following multiplication in binary number system: 111.11 2 × 101.1 2

Solve (205) 10 x (3) 10 (1110101) 2 x (1001) 2 (110) 2 x (10) 2 (1111101) 2 x (101) 2 (15) 10 x (8) 10

Binary Division

Binary Division:110 ÷10 10) 110 ( 11 - 10 ---------- 010 - 10 ------------ 000

Binary division Ex: (25) 10 ÷ (5) 10

Perform the division 111110.1 ÷101 1100.1 quotient 111110.1 5)62.5(12.5 -101 -5 -------------- --------- 0101 12.5 - 101 - 10 ------------- -------- 0000101 02.5 - 101 - 2.5 -------------- -------- 0000000 remainder 000

Solve (205) 10 ÷ (3) 10 (1110101) 2 ÷ (1001) 2 (110) 2 ÷ (10) 2 (1111101) 2 ÷ (101) 2

100)1100(11 100 --------------- 0100 100 ---------------- 0000

END
Tags