C – Bitwise Operators and Endianness Explained

bit-manipulationbit-shiftc++endianness

Does endianness matter at all with the bitwise operations? Either logical or shifting?

I'm working on homework with regard to bitwise operators, and I can not make heads or tails on it, and I think I'm getting quite hung up on the endianess. That is, I'm using a little endian machine (like most are), but does this need to be considered or is it a wasted fact?

In case it matters, I'm using C.

Best Answer

Endianness only matters for layout of data in memory. As soon as data is loaded by the processor to be operated on, endianness is completely irrelevent. Shifts, bitwise operations, and so on perform as you would expect (data logically laid out as low-order bit to high) regardless of endianness.

Related Question