Home > Common Problem > Binary addition operation

Binary addition operation

Release: 2019-06-10 17:07:58
Original
62154 people have browsed it

Binary addition operation

Binary arithmetic operations:

1. Binary addition: 0 0=0, 0 1=1, 1 0=1, 1 1=10 (carry to the high bit). When only one of the two added binary bits is 1, the result of the addition is 1; if the two binary bits are all 0, the result of the addition is still 0; and if the two added binary bits are both 1 , then the result is 10 (equivalent to 2 in decimal system), which is the "every 2 enters 1" rule.

2. Binary subtraction: 0-0=0, 0-1=1 (borrow bit from high bit) 1-0=1, 1-1=0 (modulo two addition operation or XOR operation) . When the two added binary bits are both 0 or 1, the result of the subtraction is 0; if the binary bit of the minuend is 1 and the binary bit of the subtrahend is 0, the result of the subtraction is still 1. ; And if the binary bit of the minuend is 0, and the binary bit of the subtrahend is 1, you need to borrow 1 from the high bit, but at this time, 1 is borrowed as 2.

3. Binary multiplication: 0 * 0 = 0, 0 * 1 = 0, 1 * 0 = 0, 1 * 1 = 1;

4. Binary division: 0÷ 0 = 0, 0÷1 = 0, 1÷0 = 0 (meaningless), 1÷1 = 1;

5. Logical operation binary OR operation: when 1 is encountered, 1 is obtained;

6. Binary AND operation: when encountering 0, get 0;

7. Binary NOT operation: negate each bit.

The above is the detailed content of Binary addition operation. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template