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!