title: uint8_t different decimal values for same binary
body: <p>I have the following issue using an ARM® Cortex™-M4F CPU running mbedOS 5.9.</p>
  
  <p>Say I have the binary value <code>10101000</code> and that I also have the following union/struct:</p>
  
  <pre><code>union InputWord_u
      {
          uint8_t all;
  
          struct BitField_s
          {
              uint8_t start   : 1; // D7
              uint8_t select  : 3; // D6, D5, D4
              uint8_t payload : 4; // D3, D2, D1, D0
          } bits;
      };
  </code></pre>
  
  <p>I have a simple program where I access my word and assign the values as such:</p>
  
  <pre><code>InputWord_u word;
  word.bits.start = 0b1;
  word.bits.select = 0b010;
  word.bits.payload = 0b1000;
  </code></pre>
  
  <p>Therefore, <code>word.all == 10101000</code> and is a <code>uint8_t</code>. </p>
  
  <p>If I print this as such <code>printf("%u", word.all);</code> then I receive the value of <code>133</code>. </p>
  
  <p>If I then define the following <code>uint8_t</code>:</p>
  
  <pre><code>uint8_t value = 0b10101000;
  </code></pre>
  
  <p>And print this using <code>printf("%u", value);</code> then I receive the value <code>168</code>. </p>
  
  <p>I expect both values to equal 168.</p>
  
  <p>I appreciate that this is likely me grossly misunderstanding how a Struct is represented in memory. Nevertheless, could someone please explain what is exactly going on? </p>
  
  <p>Thanks.</p>