Binary logic operation details

Source: Internet
Author: User
Operations between logical variables are called logical operations. Binary numbers 1 and 0 can logically represent "true" and "false", "yes" and "no", "Yes" and "NONE ". Such variables with logical attributes are called logical variables.
The main difference between a computer's logical operation is that the logical operation is performed by bit, and there is a relationship between the bit and the bit, unlike the addition or subtraction operation.
Logical operations mainly include three basic operations: Logical addition (also called "or" Operation), logical multiplication (also called "and" operation), and logical negation (also called "Non" operation ). In addition, the "XOR" operation is also useful.
1. Logical addition ("or" Operation)
The logical addition method is expressed by the common symbols "+" or "signature. The logic addition operation rules are as follows:
0 + 0 = 0, 0 = 0
0 + 1 = 1, 0 then 1 = 1
1 + 0 = 1, 1 limit 0 = 1
1 + 1 = 1, 1 = 1
As shown in the preceding formula, logical addition has the meaning of "or. That is to say, in a given logical variable, if one of A or B is 1, the result of the logical addition is 1; if both are 1, the logical addition is 1.
2. Logical multiplication (and)
Logical multiplication is usually represented by the symbol "×", "×", or. Logical multiplication rules are as follows:
0x0 = 0, 0x0 = 0, 0x0 = 0
0x1 = 0, 0 then 1 = 0, 0-1 = 0
1x0 = 0, 1x0 = 0, 1x0 = 0
1 × 1 = 1, 1 × 1 = 1, 1 · 1 = 1
It is not hard to see that logical multiplication has the meaning of "and. It indicates that the logical product is equal to 1 only when the logical variables involved in the operation are both set to 1.
3. Logical negation (non-calculation)
Logical non-operation is also called logical no operation. The calculation rules are as follows:
0 = 1 Non-0 equals 1
1 = 0 non-1 equals 0
4. Exclusive or logical operation (semi-plus Operation)
An exclusive or operation is usually represented by the symbol "XOR". Its operation rule is:
0 defaults 0 = 0 0 is the same as 0, and the result is 0.
0 limit 1 = 1 0 with 1 exception or, the result is 1
1 When 0 = 1 1 with 0 or, the result is 1
1 then 1 = 0 1 is the same as 1, and the result is 0.
That is, if two logical variables are different, the output is 1.

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.