What Is Bit Manipulation?
Bit operations are unary and binary operations that operate on bitwise or binary numbers in bit patterns in programming. On many ancient microprocessors, bit operations are slightly faster than addition and subtraction operations, and usually bit operations are much faster than multiplication and division. In modern architectures, this is not the case: bit operations usually operate at the same speed as addition operations (still faster than multiplication operations).
- Shift is a binary operator that is used to move each bit of a binary number in the specified direction in one direction. The overflow part will be discarded and the empty part will be filled with a certain value. In C-like languages, left shift is represented by two less than signs "<<", right shift is represented by two greater than signs ">>".
Bit operation arithmetic shift
- See also:: en: Arithmetic shift and: en: Arithmetic shift
Bit manipulation logic shift
- When applying a logical shift, fill in all the vacant parts after the shift.
- 0001 (decimal 1) << 3 (shift 3 digits left) = 1000 (decimal 8) 1010 (decimal 10) >> 2 (shift 2 digits right) = 0010 (decimal 2)
C, C++ Java Bit manipulation shifts in C, C ++ and Java
- JAVA has a unique unsigned right shift operator ">>>". This operation ignores the sign of the operands. There is also >>> = [1]