140 likes | 223 Views
University of Palestine Faculty of Engineering and Urban planning Software Engineering Department. Digital Logic Design Lab. ESGD2203. Preface. Arithmetic Binary Operations. Eng. Mohammed Timraz Electronics & Communication Engineer. 5. Arithmetic Binary Operations. 5-1 Binary Addition :.
E N D
University of Palestine Faculty of Engineering and Urban planning Software Engineering Department Digital Logic Design Lab. ESGD2203 Preface Arithmetic Binary Operations Eng. Mohammed Timraz Electronics & Communication Engineer
5. Arithmetic Binary Operations 5-1 Binary Addition:
Arithmetic Binary Operations 5-1 Binary Addition: • Example:- • 3+1=4 • By using the truth table to convert the decimal number to binary number. • = 0 1 1 • = 0 0 1 • 0 1 1 • 0 0 1 • 1 0 0 = 4 1 1 +
5. Arithmetic Binary Operations 5-2 Binary Subtraction:
5. Arithmetic Binary Operations Arithmetic Binary Operations 5-2 Binary Subtraction: Example:- 5-3=2 By using the truth table to convert the decimal number to binary number. 5 = 1 0 1 3 = 0 1 1 1 0 1 0 1 1 0 1 0 = 2 1 -
5. Arithmetic Binary Operations 5-3 Binary Multiplication:
5. Arithmetic Binary Operations Arithmetic Binary Operations 5-3 Binary Multiplication: Example:- 7×3=35 7 = 1 1 1 5 = 1 0 1 • 1 1 • 1 0 1 × 1 1 1 0 0 0 1 1 1 1 0 0 0 1 1 = 35
5. Arithmetic Binary Operations 5-4 Negative Number Presentation (Sign Number): 5.4.1 Sign Magnitude: LSB MSB Sign Bit - ve + ve Example: + 16 = 0 0 0 1 0 0 0 0 - 16 = 1 0 0 1 0 0 0 0
5. Arithmetic Binary Operations To get the negative number from positive number, there are two ways as follows: • 5-5 1st Complement: • This is the first way to get the negative number from positive number. • This way just convert each ONE (1) to ZERO (0), and each ZERO (0) to ONE (1). Example: + 13 = 1 1 0 1 + 13 = 0 0 1 0
5. Arithmetic Binary Operations 5-6 2nd Complement: There are two ways to get the 2nd complement: First Way: we can get the 2nd complement by adding 1 to the 1st complement 2nd complement = 1st complement + 1 Example: + 6 = 0 1 1 0 The 1st complement to +6 is: 1 0 0 1 2nd complement = 1st complement + 1 Then the 2nd complement for +6 is: 1 0 0 1 0 0 0 1 1 0 1 0 = -6 1 +
5. Arithmetic Binary Operations 5-6 2nd Complement: There are two ways to get the 2nd complement: Second Way: we can get the 2nd complement by convert each ONE (1) to ZERO (0) after the first ONE (1) we catch it from right side. Example: + 10 = 1 0 1 0 0 1 1 0 = - 10 - - - - - - - - - - -
5. Arithmetic Binary Operations 5-7 Division: Example: 21 ÷ 7 = 3 The result of the division operation is equal to the number of the subtraction operations to reach the smallest integer number. 21 – 7 = 14 14 – 7 = 7 7 – 7 = 0 } 1 3 subtraction operations 2 3 So, the result 3 is equal to the subtraction operations numbers
5. Arithmetic Binary Operations 5-7 Division: Example: 21 ÷ 7 = 3 The result of the division operation is equal to the number of the subtraction operations to reach the smallest integer number. 21 – 7 = 14 14 – 7 = 7 7 – 7 = 0 } 1 3 subtraction operations 2 3 The result 3 is equal to the subtraction operations numbers, So, if we convert each number to binary number and applied the subtraction operation, the result will be the number of subtraction operations The subtraction operation can be applied by using the 2nd complement and applied the addition operation as appears in the following example
Example: • 35 ÷ 7 = 5 • = 0 0 1 0 0 0 1 1 • = 0 0 0 0 0 1 1 1 • -7 = 1 1 1 1 1 0 0 1 • = 0 0 1 0 0 0 1 1 • -7 = 1 1 1 1 1 0 0 1 • 1 0 0 0 1 1 1 0 0 • -7 = 1 1 1 1 1 0 0 1 0 0 0 1 0 1 0 1 • And complete the operation to reach ZERO, we will complete it by 5 addition’s operations. + N.C +