title: "Bit-fields are assigned left to right on some machines and right to left on others"- unable to get the concept from "The C Programming Language" book
body: <p>I was going through the text &quot;The C Programming Language&quot; by Kernighan and Ritchie. While discussing about bit-fields at the end of that section, the authors say:</p>
  <blockquote>
  <p>&quot;Fields are assigned left to right on some machines and right to left on others. This means that although fields are useful for maintaining internally-defined data structures, the question of which end comes first has to be carefully considered when picking apart externally-defined data; programs that depend on such things are not portable.&quot;</p>
  <p><em>- The C Programming Language [2e] by Kernighan &amp; Ritchie</em> <em>[Section 6.9, p.150]</em></p>
  </blockquote>
  <p>Strictly I do not get the meaning of these lines. Can anyone please explain me with a possible diagram?</p>
  <hr />
  <p>PS: Well I have taken a computer organization and architecture course. I know how computers deal with bits and bytes. In a computer system, the smallest unit of information is a single bit which can be either 0 or 1. 8 such bits form a byte. Memories are byte-addressable, which means that each byte in the memory has an address associated with it. But usually, the processors have word lengths as 2 bytes (very old systems),4 bytes, 8 bytes... This means in one memory cycle, the CPU can take up a word length number of bytes from the main memory and put it inside its registers. Now how these bytes are placed in registers depends on the endianness of the system.</p>
  <p>But I do not get what the authors mean by &quot;left to right&quot; or &quot;right to left&quot;. The words seem like they are related to the endianness but endianness depends on the CPU and C compilers have nothing to do with it... The question which comes to my mind is &quot;left to right&quot; of &quot;what&quot;? What object are the authors referring to?</p>