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 −

  1. Binary Addition

  2. Binary Subtraction

  3. Binary Multiplication

  4. 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 −

  1. 0 + 0 = 0

  2. 0 + 1 = 1

  3. 1 + 0 = 1

  4. 1 + 1 = 10 (Sum = 0 & Carry = 1)

让我们考虑一些示例来理解二进制加法。

Let us consider some examples to understand the binary addition.

Example 1

添加两个二进制数,1101 和 1110。

Add two binary numbers, 1101 and 1110.

Solution

如下描述了给定二进制数的二进制加法−

The binary addition of the given binary numbers is described below −

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.

Example 2

添加 1010 和 11011。

Add 1010 and 11011.

Solution

如下说明给定数字的二进制加法−

The binary addition of given numbers is explained below −

binary addition numbers

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 −

  1. 0 – 0 = 0

  2. 1 – 0 = 1

  3. 0 – 1 = 1 (borrow 1 from the next higher bit)

  4. 1 – 1 = 0

让我们看几个例子来理解二进制减法。

Let us see some examples to understand the binary subtraction.

Example 1

从 1101 中减去 1100。

Subtract 1100 from 1101.

Solution

给定二进制数的减法如下 −

The subtraction of given binary numbers is given below −

1101 – 1100 = 0001

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.

Example 2

从 1111 中减去 101。

Subtract 101 from 1111.

Solution

下面解释给定二进制数的减法:

The subtraction of given binary numbers is explained below −

binary subtraction numbers

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.

Example 3

从 1101 中减去 1011。

Subtract 1011 from 1101.

Solution

1101 和 1011 的二进制减法如下:

The binary subtraction of 1101 and 1011 is given below −

binary subtraction number

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 −

  1. 0 × 0 = 0

  2. 0 × 1 = 0

  3. 1 × 0 = 0

  4. 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.

Example 1

对 1101 和 11 求积。

Multiply 1101 and 11.

Solution

下文描述了指定数字的二进制乘法:

The binary multiplication of given numbers is described below −

binary multiplication

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.

Example 2

对 11011 和 110 求积。

Multiply 11011 and 110.

Solution

下文演示了给定二进制数字的乘法:

The multiplication of given binary numbers is demonstrated below −

binary multiplication numbers

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 −

  1. 0 ÷ 0 = Undefined

  2. 0 ÷ 1 = 0 with remainder = 0

  3. 1 ÷ 0 = Undefined

  4. 1 ÷ 1 = 1 with remainder = 0

Binary Division Procedure

  1. Start dividing from the leftmost bits of the dividend by the divisor.

  2. Multiply the quotient obtained by the divisor and subtract from the dividend.

  3. 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.

Example 1

将 110011 除以 11。

Divide 110011 by 11.

Solution

对给定二进制数字的除法如下所示 -

The division of the given binary numbers is explained below −

110011 ÷ 11 = 10001

binary division

在此二进制除法示例中,得到的商是 10001,余数为 0。

In this example of binary division, the quotient obtained is 10001 and the remainder is 0.

Example 2

将 11011 除以 10。

Divide 11011 by 10.

Solution

将 11011 除以 10 的二进制除法解释如下 −

The binary division of 11011 by 10 is explained below −

11011 ÷ 10 = 1101

binary division numbers

在该示例中,商为 1101,余数为 1。

In this example, the quotient is 1101 and the remainder is 1.

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.