user1091856
user1091856

Reputation: 3158

Confused with endianess: bits or bytes?

I extracted this from a tutorial:

Little-Endian order is the one we will be using in this document, and unless stated specifically you should assume that Little-Endian order is used in any file. The alternate is Big-Endian ordering. So let’s see an example. Take the following stream or 8 bits 10001110 If you have been following the document so far, you would quickly calculate the value of this 8-bit number as being 1x2^7 + 0x2^6 + … + 1x2^1 + 0x2^0 = 142 This is an example of Little-Endian ordering. However, in Big-Endian ordering we need to read the number in the opposite direction 1x2^0 + 0x2^1 + … + 1x2^6 + 0x2^7 = 113

Is this correct?

I used to think that endianess has to do with order that the BYTES (not the bits) are read.

Upvotes: 4

Views: 177

Answers (3)

Marty Fried
Marty Fried

Reputation: 507

It wouldn't make sense to reorder bits, and it would be pretty confusing to boot. CPUs don't read simgle bits, they read bytes, or combinations of bytes, at one time, so that's the ordering that's important.

When they store a number made up of multiple bytes, they can either store it from left to right, making the high-order byte lowest in memory, or right to left, with the low-order byte lowest in memory.

Upvotes: 1

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272772

Yes, in the context of memory/storage, endianness indeed refers to byte ordering (typically). What would it mean to say that e.g. the least-significant bit "comes first"?

Bit endianness is relevant in some situations, for instance when sending data over a serial bus.

Upvotes: 5

You are correct - that quote you have there is rubbish, IMHO.

Upvotes: 1

Related Questions