Arithmetic in Binary
Arithmetic in Binary
Binary Addition
Binary Number Decimal Number ႔ ။ Binary
Number 1(One) and 0(Zero) ။ Digit ႕
(4) ႔ ။
႔ Binary Number ။ ။
႔ 0(Zero)၊ 1(One)၊ 1+1 Carry 1 ႔ ။၄ (4)
…
Binary Addition
X Y Sum Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
X Augend
+ Y Addend
Sum with or without a carry
-----------------------------------------------------------------------------------------------------------
႔၏ ႔…။
Programmingknowledge.blogspot.com Assembly Language- Number System
---------------------------------------------------------------------------------------------------------------------
(၂)။ 14 + 13 = ?
1 1 - Carry
14 00001110 - Augend
+13 + 00001101 - Addend
27 00011011 - Sum
… 1+1 Sum = 0 ႔ Carry = 1 ။
၄ Sum 0 ႕ ႔1 Carry ။ 1+ 1+ 1
Sum =1 ႔ Carry = 1 ။ Sum 1 ႕ ႔1 Carry
။ 27 ႔ Result
။ ႔ ။
(၃)။ 11.01<2> + 10.11<2> = ?
Solution:
1 1 1 1 - Carry
1 1.0 1 - Augend
+ 1 0.1 1 - Addend
1 1 0.0 0 - Sum
Result: 11.01<2> + 10.11<2> = 110.00<2>
၊ ၊ ႔ Binary Number
႔ ။ ႔ ႕ Binary Number
႔။
Binary Subtraction
Binary Number ။ ႕ Binary Number
inverse operation of addition ႔ ။ ႔ Binary Addition
႔ ႔ ။ ႔ 0(Zero) ၊
1(One) ၊ Borrow 1 ႔ ။ ။
Binary Subtraction
X Y Difference Borrow
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
X - Minuend
- Y - Subtrahend
Difference
X and Y ႔ Binary Number ။ Diffference ႔
Result ။ 0 - 1 Remainder (or) Difference
႔1 ။ ႕
1 ။ ႔ ။
။
-----------------------------------------------------------------------------------------------------------
႔၏ ႔…။
Programmingknowledge.blogspot.com Assembly Language- Number System
---------------------------------------------------------------------------------------------------------------------
(၁)။ 13 – 5 = ?
Solution:
13 0 0 0 0 1 1 0 1 - Minuend
-5 - 0 0 0 0 0 1 0 1 - Subtrahend
8 0 0 0 0 1 0 0 0 - Difference
။ Binary Bit Binary Bit
႕ Borrow ။ ။ ႔
1 - 1 = 0 ။ Borrow Differerence = 0 ။ ႔
။ ။ 1 - 0 ။
1 - 0 = 1 ။ Borrow Result 1 Difference
။ Result Check ။ 13 - 5 = 8 ၊ ႔
Result 0 0 0 0 1 0 0 0<2> Decimal Number
8 ႔ ။ ။ Borrow
႕ ။
(၂)။ 19 – 8 = ?
Solution:
0 - Borrow
19 0 0 0 1 0 0 1 1 - Minuend
-8 -0 0 0 0 1 0 0 0 - Subtrahend
11 0 0 0 0 1 0 1 1 - Difference
။ ႔ 1-0=1 Difference = 1 ။
။0-0=0 Difference = 0 ။ 0-1
။ Binary Subtraction
Difference=1 ။ ႕ 1 (၅) 1
0 ။ Result Check ။ ႔ ။
႔ ။ Binary Subtraction
။ Borrow ။
(၃)။ 17 – 11 = ?
Solution: 1 1
0 2 2 2 - Borrow
17 0 0 0 1 0 0 0 1 - Minuend
-11 - 0 0 0 0 1 0 1 1 - Subtrahend
6 0 0 0 0 0 1 1 0 - Difference
။ ။ 1-1= 0 Difference = 0
။ 0-1 ။ ႕ 1
။ Binary Number Base 2 ။ ႕ 1
2 ႔ ။ 2 -1 =1 Difference = 1 ။
႔ ။ ႕
။ ႕ ႕ ႕
-----------------------------------------------------------------------------------------------------------
႔၏ ႔…။
Programmingknowledge.blogspot.com Assembly Language- Number System
---------------------------------------------------------------------------------------------------------------------
။ Column 5 ။ ။
Column5 = 0 Column4 2 ႔ ။ Column4 Column3 1
Column4 = 1 ။ Column3 Column2
1 Column3 = 1 ။ Column2 ႕ 1
2 2 - 1 = 1 Difference = 1 ။
႔ ။
႔ ႔ Binary Number Binary Subtraction
၊ (၃) 2 ။ ႔
။ Result ။ ႔ Binary
Number ႔ ။
(၄)။ 1.001 – 0.110 = ?
1
Solution: 0 2 2 - Borrow
1.0 0 1 - Minuend
- 0 . 1 1 0 - Subtrahend
0.0 1 1 - Difference
So, 1.001<2> – 0.110<2> = 0.011<2>
၊ ၊ ႔ Binary Number
႔ ။ ႔ ႔ Binary Number
႔ ။
Binary Number Complementation Method ႔
။ ႔ Number System (၁) Complementation Method
။
။
-----------------------------------------------------------------------------------------------------------
႔၏ ႔…။
Programmingknowledge.blogspot.com Assembly Language- Number System
---------------------------------------------------------------------------------------------------------------------
End-Carry ႔ Binary Number (2) Result
။ ။ 1’s Complement ႔
႔ ။
(၁)။ 19 – 6 = ?
Solution:
19<10> Minuend 0 0 0 1 0 0 1 1<2>
6<10> Subtrahend 0 0 0 0 0 1 1 0<2>
1’s complement of Subtrahend (6<10>) 1 1 1 1 1 0 0 1<2>
Add this complement to Minuend(19<10> ):
19 0 0 0 1 0 0 1 1
1’s complement of 6 + 1 1 1 1 1 0 0 1
1 0 0 0 0 1 1 0 0
+ 1
0 0 0 0 1 1 0 1 13
So, 19 – 6 = 0000 1101<2>
။ ႔ 6<10> = 0000 0110<2> Invert
1’s Complement ။ ႔ 1’s complement 0000
0110<2> ႕ 19<10> = 0001 0011<2> ႔ ။ End-
Carry ၄ End-Carry Result ႔ ။
Binary Number ႔ Binary Addition
႔ ႔ ။ Result Check
။ 0000 1101<2> = 13<10> ႔ ။ 19 – 6 = 13 ။
႔ ။
။
(၂)။ 17 – 8 = ?
Solution:
17<10> Minuend 0 0 0 1 0 0 0 1<2>
8<10> Subtrahend 0 0 0 0 1 0 0 0<2>
1’s complement of Subtrahend(8<10>) 1 1 1 1 0 1 1 1<2>
Add this complement to Minuend(17<10>) :
17 0 0 0 1 0 0 0 1
1’s complement of 8 + 1 1 1 1 0 1 1 1
1 0 0 0 0 1 0 0 0
+ 1
0 0 0 0 1 0 0 1 9
So, 17 – 8 = 0000 1001<2>
… ႔ 8<10> = 0000 1000<2> Invert
1’ s Complement ။ ႔ 1’s Complement
0000 1000<2> ႕ 17<10> = 0001 0001<2> ႔ ။
End-Carry ၄ End-Carry Result ႔
။ ။ Result Check
-----------------------------------------------------------------------------------------------------------
႔၏ ႔…။
Programmingknowledge.blogspot.com Assembly Language- Number System
---------------------------------------------------------------------------------------------------------------------
0000 1001<2> = 9<10> ႔ ။ ။
႔ ႔ ႔ ။
(၃)။ 11.01 – 01.10 = ?
Solution:
Minuend 1 1.0 1<2>
Subtrahend 0 1.1 0<2>
1’s complement of Subtrahend 1 0.0 1<2>
Add this complement to Minuend:
Minuend 11.01
1’s complement of Subtrahend + 10.01
1 01.10
+1
0 1 . 1 1 Difference
So, 11.01<2> – 01.10<2> = 01.11<2>
၊ ၊ ႔ 1’s Complementation Method
Binary Number ႔ ။ Binary Number
2’s Complementation Method ႔။
-----------------------------------------------------------------------------------------------------------
႔၏ ႔…။
Programmingknowledge.blogspot.com Assembly Language- Number System
---------------------------------------------------------------------------------------------------------------------
5<10> Subtrahend 0 0 0 0 0 1 0 1<2>
1’s complement of Subtrahend(5<10> ) 1 1 1 1 1 0 1 0<2>
2’s complement of Subtrahend(5<10> ) 11111010
+ 1
1 1 1 1 1 0 1 1 -5
Add this 2’s complement to Minuend(17<10>):
17 00010001
+(-5) + 11111011
12 1 0 0 0 0 1 1 0 0 Difference
End-Carry is ignored. So, 17 – 5 = 0000 1100<2>
။ ။ 5<10> = 0000 0101<2>
Invert 1’ s Complement ။ ႔ 1’s Complement
0000 0101<2> ႕ 1 2’s complement ။
Positive Binary Number Negative Binary Number
။ ႔ -5 ႕ Binary Number ။
၄ Negative Binary Number 17<10> = 0001 0001<2> ႔ ။
End-Carry ၄ End-Carry Result
။ ။
Result Check ။ 17 – 5 =12 ႔
Binary Number ႕ 12 ။
End-Carry ။ ႔ ႔
End-Carry ႔ ။
။
(၂)။ 10 – 24 = ?
Solution:
10 + (-24) = -14
10<10> Minuend 0 0 0 0 1 0 1 0<2>
24<10> Subtrahend 0 0 0 1 1 0 0 0<2>
1’s complement of Subtrahend(24<10>) 1 1 1 0 0 1 1 1<2>
-----------------------------------------------------------------------------------------------------------
႔၏ ႔…။
Programmingknowledge.blogspot.com Assembly Language- Number System
---------------------------------------------------------------------------------------------------------------------
complementation method ႔
။ ႕ ၊ ႔
႔ ႔ ႔ ။
။
Binary Multiplication
Binary Number Decimal Number
႔ ။ ႔ ႔ General Rule
။ ။
Binary Multiplication
X Y XxY
0 0 0
0 1 0
1 0 0
1 1 1
X - Multiplicand
x Y - Multiplier
Products
X and Y ႔ Binary Number ။ Products ႔
Result ။ ႔1x1 1
0(Zero) ႔ ။ ။
(၁)။ 12 x 9 = ?
Solution:
12 1 1 0 0 - Multiplicand
9 x 1 0 0 1 - Multipler
1100
0000
0000
+1100 _
108 1 1 0 1 1 0 0 - Products
So, 12 x 9 = 1101100<2>
႔ Result ႔ ႔
။ Binary Number Decimal Number ႔ ။
1x1 1 0 ။
Result Decimal Number ႔ Check ။ Result ။
၊ ႔ ႔ ။ ႔ ႔
Decimal Number ႔ Check ႔ ။
။
-----------------------------------------------------------------------------------------------------------
႔၏ ႔…။
Programmingknowledge.blogspot.com Assembly Language- Number System
---------------------------------------------------------------------------------------------------------------------
(၂)။ 9 x 5 = ?
Solution:
9 1 0 0 1 - Multiplicand
5 x 1 0 1 - Multiplier
1001
0000
+1001 _
45 1 0 1 1 0 1 - Products
So, 9 x 5 = 101101<2>
Binary Number ။ ႔ ။
၊ ၊ ႔ ႔
။
(၃)။ 3.5 x 1.5 = ?
Solution:
3.5 1 1.1 - Multiplicand
1.5 x 1.1 - Multiplier
111
+111 _
5.25 1 0 1.0 1 - Products
So, 3.5 x 1.5 = 101.01<2>
Result ။ Decimal Number ႔ ။
။ ။
(၄)။ 10.5 x 4.5 = ?
Solution:
10.5 1 0 1 0.1 - Multiplicand
4.5 x 1 0 0.1 - Multiplier
10101
00000
00000
+10101 _
47.25 1 0 1 1 1 1.0 1 - Products
So, 10.5 x 4.5 = 101111.01<2>
၊ ၊ ႔ Binary Number
႔ ။ Binary Division
။
Binary Division
Binary Division Decimal Division ႔ ။ ႔
Left to Right ။ Digit
။ Decimal Number
႔ ။ Binary Division ၊ ၊
-----------------------------------------------------------------------------------------------------------
႔၏ ႔…။
Programmingknowledge.blogspot.com Assembly Language- Number System
---------------------------------------------------------------------------------------------------------------------
႔ General Rule ။ ႔ ႔
႔ ။
(၁)။ 22 / 3 = ?
Solution:
Dividend 22 10110<2>
Divisor 3 11<2>
Quotient
Divisor Dividend
Quotient
Divisor
Remainder Remainder
Decimal Division Binary Division
So, 22 / 3 Quotiend = 111<2> And Remainder = 1
႔ ။ Binary Division ။
႔ Left to Right ။ Digit 10<2>
။ 101<2>
။ ။ 101-11 = 10
။ ႕ 1 ။
101-11 = 10 ။ ႕ 0
။ 100-11 =1 ႔ ။ ႔ 22/3 ႕
-111 -1 ။ ။
။
(၂)။ 15 / 4 = ?
Solution:
Dividend 15 1111<2>
Divisor 4 100<2>
Quotient
Divisor Dividend
Quotient
Divisor
Remainder Remainder
Decimal Division Binary Division
So, 15 / 4 Quotiend = 11<2> And Remainder = 11<2>
-----------------------------------------------------------------------------------------------------------
႔၏ ႔…။
Programmingknowledge.blogspot.com Assembly Language- Number System
---------------------------------------------------------------------------------------------------------------------
Binary Number ႔ ႔ ႔
။ ႔ ။ Binary
Subtraction ႔ ။
႔ ႕
။ Arithmetic in Octal Octal Number
၊ ၊ ၊ … ႔ ။
၊ ၊ ။
-----------------------------------------------------------------------------------------------------------
႔၏ ႔…။