Reputation: 381
I work with binary protocol, so it's normally to use:
int32_t number = SOME_NUMBER;
CFSwapInt32BigToHost(number);
But what's about int8_t?
Upvotes: 0
Views: 108
Reputation: 16660
Endianess usually refers to the order of bytes. Since every byte has its own address, a multi-byte word can be ordered in two (or more, but typically it has big-endianness or little-endiness) different directions, higher byte higher address or lower byte higher address. So you need a byte swap.
Bits are not addressable. So there is no need to deal with endianness. And even if there is a operation that indexes a bit, nobody would be that crazy to make the bit 0 the most significant. So you do not need a bit swap.
Upvotes: 1