Modulo 2 operation

Source: Internet
Author: User
Tags arithmetic
1. What is modulo 2 operation?
First of all, what is modulo 2? Modulo: The remainder, then, modulo 2, is divided by 2 to obtain the remainder.
Again, what is arithmetic? is subtraction.
That is, the modulo 2 operation, can be opened up in this way: a given number divided by 2 after the subtraction between the remainder of the operation.
In actual use, the modulo 2 operation is used in the binary case, that is, 0/1 in addition to 2 after the remainder of the operation, plainly, is the operation of 0 and 1.
2. Algorithms for modulo 2 operations
This thing is the same as the law of arithmetic, do not delve into, is the person rules. One thing to be aware of is that modulo 2 operations do not carry or borrow.
In the same way as arithmetic, modulo 2 also includes modulo 2 plus, modulo 2 minus, modulo 2 multiplication, and modulo 2 in addition to four binary operations. Moreover, the modulo 2 operation also uses the same operator as arithmetic, which means "+" for modulo 2 plus, "-" for modulo 2 minus, "X" or "•" Represents modulo 2 multiply, "÷" or "/" means 2 apart. Unlike arithmetic, the modulo 2 operation does not consider carry and borrow, i.e. modulo 2 addition is a binary addition without carry, modulo 2 subtraction is a binary subtraction operation without borrow. Thus, when the two bits phases are operated, the values of the two bits determine the result of the operation and are not affected by the previous operation, nor will it be affected next time.

① modulo 2 The addition operation is defined as:
0+0=0 0+1=1 1+0=1 1+1=0
For example, 0101+0011=0110, column-based calculation:
0 1 0 1
+ 0 0 1 1
──────
0 1 1 0
The ② modulo 2 subtraction operation is defined as:
0-0=0 0-1=1 1-0=1 1-1=0
For example, 0110-0011=0101, column-based calculation:
0 1 1 0
-0 0 1 1
──────
0 1 0 1
The ③ modulo 2 multiplication operation is defined as:
0x0=0 0x1=0 1x0=0 1x1=1
The multi-bit binary mode 2 multiplication is similar to the common meaning of the multi-bit binary multiplication, the difference is that the latter accumulates the intermediate result (or part of the product) with the addition of carry, and the modulo 2 multiplication to the intermediate result of the processing method is the modulo 2 addition. For example, 1011x101=100111, column-based calculation:
1 0 1 1
X1 0 1
──────
1 0 1 1
0 0 0 0
+ 1 0 1 1
────────
1 0 0 1 1 1
The ④ modulo 2 division operation is defined as:
0÷1=0 1÷1=1
The multi-bit binary modulo 2 division is also similar to the multi-bit binary division in the normal sense, but the two adopt different rules on how to determine the quotient of the problem. The latter according to the binary subtraction with the borrow, according to the remainder of the deduction number is sufficient to determine whether the quotient of 1 or 0, if enough to reduce the quotient of 1, otherwise quotient 0. The multi-position modulo 2 division uses modulo 2 subtraction, without the borrow binary subtraction, so it makes no sense to consider whether the remainder is sufficient to subtract the number. In fact, in the CRC operation, always guaranteed that the first of the divisor is 1, then the quotient of modulo 2 division is determined by the result of modulo 2 division of the first and the first bits of the remainder. Since the first digit is always 1, according to the modulo 2 division algorithm, then the first digit of the remainder is 1 on the quotient 1, 0 on the quotient 0. For example 1100100÷1011=1110 ... 110, Column vertical calculation:
1 1 1 0
────────
1 0 1 1)1 1 0 0 1 0 0
-1 0 1 1
──────
1 1 1 1
-1 0 1 1
──────
1 0 0 0
-1 0 1 1
──────
0 1 1 0
-0 0 0 0
──────
1 1 0
Summary: By comparison we are not difficult to find that the modulus 2 plus and modulo 2 minus two operations and the logical XOR operation of the same arithmetic, in addition, modulo 2 multiplication method is based on modulo 2 plus subtraction, so we can think of modulo 2 operation as a simple XOR operation. In fact, the CRC divider is made up of XOR gates and sequential circuits.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.