Computer Logical Organization 简明教程
Digital Electronics - Binary Arithmetic
二进制算法是数字电子和计算机工程领域的基本概念之一。它基本上是二进制数的数学,允许对二进制数执行各种算术运算。我们知道二进制数系统有两个数字,即 0 和 1,它们用于表示数字系统的开或关状态。因此,二进制算法构成了数字计算的基础。
Binary arithmetic is one of the fundamental concepts in the field of digital electronics and computer engineering. It is basically the mathematics of binary numbers allow to perform various arithmetic operations on binary numbers. We know that the binary number system has two digits, i.e., 0 and 1 which are used to represent the ON or OFF states of the digital systems. Hence, binary arithmetic forms the foundation of the digital computing.
在本章中,我们将讨论以下四个主要的二进制算术运算−
In this chapter, we will discuss the following four main binary arithmetic operations −
-
Binary Addition
-
Binary Subtraction
-
Binary Multiplication
-
Binary Division
让我们详细讨论每个这些二进制算术运算以及求解示例。
Let’s discuss each of these binary arithmetic operations in detail along with solved examples.
Binary Addition
在二进制算术中,两个二进制数相加的过程称为二进制加法。其中,二进制数仅由 0 和 1 组成。在二进制加法中,当总和小于 1 时产生进位。
In binary arithmetic, the process of adding two binary numbers is called binary addition. Where, the binary numbers consist of only 0 and 1. In the binary addition, a carry is generated when the sum is greater than 1.
Rules of Binary Addition
两个二进制数的加法按以下二进制算术规则执行−
The addition of two binary numbers is performed according to these rules of binary arithmetic −
-
0 + 0 = 0
-
0 + 1 = 1
-
1 + 0 = 1
-
1 + 1 = 10 (Sum = 0 & Carry = 1)
让我们考虑一些示例来理解二进制加法。
Let us consider some examples to understand the binary addition.
Explanation
添加 1(第一个数的最右位)和 0(第二个数的最右位)。产生 1 + 0 = 1(因此,将 1 写为和位)。
Add 1 (rightmost bit of first number) and 0 (rightmost bit of the second number). It gives 1 + 0 = 1 (thus, write down 1 as sum bit).
添加 0(第一个数的倒数第二位)和 1(第二个数的倒数第二位)。产生 0 + 1 = 1(将 1 写为和位)。
Add 0 (second rightmost bit of first number) and 1 (second rightmost bit of the second number). It gives 0 + 1 = 1 (write down 1 as sum bit).
添加 1(第一个数的第三位)和 1(第二个数的第三位)。产生 1 + 1 = 10(将 0 写为和,1 写为进位)。
Add 1 (third rightmost bit of first number) and 1 (third rightmost bit of second number). It gives 1 + 1 = 10 (write down 0 as sum and 1 as carry).
添加 1(第一个数的最左位)、1(第二个数的最左位)和 1(进位)。产生 1 + 1 + 1 = 11(将 1 写为和,1 写为进位)。
Add 1 (leftmost bit of the first number), 1 (leftmost bit of second number) and 1 (carry). It gives 1 + 1 + 1 = 11 (write down 1 as sum and 1 as carry).
在和中写下环绕进位 1。
Write the end around carry 1 in the sum.
因此,结果为 11011。
Thus, the result is 11011.
Explanation
将 0(第一个数的最右侧位)和 1(第二个数的最右侧位)相加。得 0 + 1 = 1(将 1 作为和写下来)。
Add 0 (rightmost bit of first number) and 1 (rightmost bit of second number). It gives 0 + 1 = 1 (write down 1 as sum).
将 1(第一个数的次右侧位)和 1(第二个数的次右侧位)相加。得 1 + 1 = 10(将 0 作为和写下来,将 1 作为进位)。
Add 1 (second rightmost bit of first number) and 1 (second rightmost bit of second number). It gives 1 + 1 = 10 (write down 0 as sum and 1 as carry).
将 0(第一个数的第三右侧位)、0(第二个数的第三右侧位)和 1(进位)相加。得 0 + 0 + 1 = 1(将 1 作为和写下来)。
Add 0 (third rightmost bit of first number), 0 (third rightmost bit of second number), and 1 (carry). It gives 0 + 0 + 1 = 1 (write down 1 as sum).
将 1(第一个数的最左侧位)和 1(第二个数的次左侧位)相加。得 1 + 1 = 10(将 0 作为和写下来,将 1 作为进位)。
Add 1 (leftmost bit of first number) and 1 (second leftmost bit of second number). It gives 1 + 1 = 10 (write down 0 as sum and 1 as carry).
将 1(第二个数的最左侧位)和 1 进位相加。得 1 + 1 = 10(将 0 作为和写下来,将 1 作为尾进位)。
Add 1 (leftmost bit of second number) and 1 carry. It gives 1 + 1 = 10 (write down 0 as sum and 1 as the end around carry).
因此,1010 和 11011 的和是 100101。
Hence, the sum of 1010 and 11011 is 100101.
Binary Subtraction
在二进制算术中,二进制减法是一种用来找出两个二进制数差值的数学运算。
In binary arithmetic, binary subtraction is a mathematical operation used to find the difference between two binary numbers.
在二进制减法中,从最右侧位开始,对二进制数的每一位进行减法。
In binary subtraction, each bit of the binary numbers is subtracted, starting from the rightmost bit.
另外,如果需要,可以从更高位借用借位。
Also, a borrow bit can be taken from higher bits if require.
Rules of Binary Subtraction
二进制减法按照以下二进制算术规则执行 −
The binary subtraction is performed as per the following rules of binary arithmetic −
-
0 – 0 = 0
-
1 – 0 = 1
-
0 – 1 = 1 (borrow 1 from the next higher bit)
-
1 – 1 = 0
让我们看几个例子来理解二进制减法。
Let us see some examples to understand the binary subtraction.
Explanation
从 1(第一个数的最右侧位)中减去 0(第二个数的最右侧位)。得 1 – 0 = 1(将 1 作为差值写下来)。
Subtract 0 (rightmost bit of second number) from 1 (rightmost bit of first number). It gives 1 – 0 = 1 (write down 1 as difference).
从 0(第二个数字的次右位)中减去 0(第一个数字的次右位)。结果为 0 – 0 = 0。
Subtract 0 (second rightmost bit of second number) from 0 (second rightmost bit of first number). It gives 0 – 0 = 0 as result.
从 1(第二个数字的第三右位)中减去 1(第一个数字的第三右位)。结果为 1 – 1 = 0。
Subtract 1 (third rightmost bit of second number) from 1 (third rightmost bit of first number). It gives 1 – 1 = 0 as result.
从 1(第二个数字的最左位)中减去 1(第一个数字的最左位)。结果为 1 – 1 = 0。
Subtract 1 (leftmost bit of second number) from 1 (leftmost bit of first number). It gives 1 – 1 = 0 as result.
因此,1101 和 1100 的差为 0001。
Thus, the difference of 1101 and 1100 is 0001.
Explanation
减去最右边的位:1 – 1 = 0
Subtract rightmost bits: 1 – 1 = 0
减去第二个最右边的位:1 – 1 = 1
Subtract second rightmost bits: 1 – 1 = 1
减去第三个最右边的位:1 – 1 = 0
Subtract third rightmost bits: 1 – 1 = 0
减去最左边的位:1 – 0 = 1
Subtract leftmost bits: 1 – 0 = 1
因此,结果为 1010。
Thus, the result is 1010.
Explanation
减去最右边的位:1 – 1 = 0。
Subtract rightmost bits: 1 – 1 = 0.
减去第二个最右边的位:0 – 1 = 1。从更高位的下一位借 1。
Subtract second rightmost bits: 0 – 1 = 1. A borrow 1 is taken from the next higher bit.
减去第三个最右边的位:0 – 0 = 0。将 1 借给前一位。
Subtract third rightmost bits: 0 – 0 = 0. The 1 borrow is given to previous bit.
减去最左边的位:1 – 1 = 0。
Subtract leftmost bits: 1 – 1 = 0.
因此,1101 和 1011 的差为 0010。
Thus, the difference of 1101 and 1011 is 0010.
Binary Multiplication
在二进制算术中,二进制乘法是将两个二进制数相乘并获得其乘积的过程。
In binary arithmetic, binary multiplication is the process of multiplying two binary numbers and obtain their product.
在二进制乘法中,我们对一个二进制数字的每一位乘以另一个二进制数字的每一位,然后再对部分积相加,以得到最终结果。
In binary multiplication, we multiply each bit of one binary number by each bit of another binary number and then add the partial products to obtain the final product.
Rules of Binary Multiplication
两个二进制数字相乘是基于二进制运算的下列规则进行的:
The multiplication of two binary numbers is performed as per the following rules of binary arithmetic −
-
0 × 0 = 0
-
0 × 1 = 0
-
1 × 0 = 0
-
1 × 1 = 1
很明显,二进制乘法类似于十进制乘法。让我们通过一些解析示例来理解二进制乘法。
It is clear that the binary multiplication is similar to the decimal multiplication. Let us understand the binary multiplication with the help of solved examples.
Explanation
将第二个数字的最右侧位 1 与第一个数字 (1101) 的每一位数相乘。
Multiply the rightmost bit of the second number, 1 by each bit of the first number (1101).
现在,将部分积向左移动一位,以执行下一个乘法操作。
Now, shift the partial product one position to the left to perform the next multiplication.
将第二个数字的最左侧位 1 与第一个数字 (1101) 的每一位数相乘。
Multiply the leftmost bit of the second number, 1 by each bit of the first number (1101).
最后,将所有部分积相加,以得到最终结果。
Finally, sum up all the partial products to obtain the final product.
因此,1101 与 11 的积为 100111。
Hence, the product of 1101 and 11 is 100111.
Explanation
将第二个数字的最右侧位 (0) 与第一个二进制数字 (11011) 的每一位相乘。
Multiply rightmost bit of the second number (0) by each bit of the first binary number (11011).
将部分积向左移动一位。
Shift the partial product one position to the left.
将第二个数字的第二右侧位 (1) 与第一个二进制数字 (11011) 的每一位相乘。
Multiply the second rightmost bit of the second number (1) by each bit of the first binary number (11011).
再次,将乘积向左移动一个位置。
Again, shift the partial product one position to the left.
将第二个数字(1)的最低位乘以第一个数字的每一位。
Multiply the leftmost bit of the second number (1) by each bit of the first number.
然后,对所有乘积求和以获得最终积。
Then, sum up all the partial products to obtain the final product.
因此,11011 和 110 的积为 10100010。
Hence, the product of 11011 and 110 is 10100010.
Binary Division
二进制除法是用于在将一个二进制数字除以另一个二进制数字时求商和余数的基本算术运算之一。
Binary division is one of the basic arithmetic operations used to find the quotient and remainder when dividing one binary number by another.
Rules of Binary Division
在将一个二进制数字除以另一个二进制数字时,使用以下二进制算术规则 -
The following rules of binary arithmetic are utilized while diving one binary number by another −
-
0 ÷ 0 = Undefined
-
0 ÷ 1 = 0 with remainder = 0
-
1 ÷ 0 = Undefined
-
1 ÷ 1 = 1 with remainder = 0
Binary Division Procedure
-
Start dividing from the leftmost bits of the dividend by the divisor.
-
Multiply the quotient obtained by the divisor and subtract from the dividend.
-
Bring down the next bits of the dividend and repeat the division process until all the bits of given divided are used.
让我们考虑一些已解决的例程来了解二进制除法。
Let us consider some solved examples to understand the binary division.
Conclusion
二进制算术涉及对二进制数执行的算术运算。通常,四则基本算术运算即加法、减法、乘法和除法是对二进制数执行的。
Binary arithmetic involves arithmetic operations performed on binary numbers. In general, the four basic arithmetic operations namely addition, subtraction, multiplication, and division are performed on binary numbers.
在本章中,我们解释了执行所有四则基本二进制算术运算的规则和程序,同时还提供了求解示例。
In this chapter, we explained the rules and procedure to perform all the four basic binary arithmetic operations along with solved examples.