Bit operators
suggest changeThe result of a shift depends on the width of the operand type, not on whether the machine is called 64-bit. int is often 32 bits on both 32-bit and 64-bit platforms. Before C++20, left-shifting a negative signed value is undefined behavior, so this is not a portable way to inspect width:
int a = ~0;
int b = a << 1;
On a platform where int is wider or narrower, a well-defined shift of an unsigned value of that width can differ. A small microcontroller may use a 16-bit int.
Endianness does not affect the bitwise operators themselves. A right shift (>>) moves bits toward the least significant bit, and XOR combines corresponding bits. Endianness matters only for how a multi-byte value is stored in memory, whether or not you use bitwise operators.
^ - bitwise XOR (exclusive OR)
~ - bitwise NOT (unary complement)