title: Does a uint64 take 8 bytes storage?
body: <p>Official document says uint64 is an unsigned integer of 64-bits, does that mean any uint64 number should take 8 bytes storage, no matter how small or how large it is?</p>
  
  <p>Edit:</p>
  
  <p>Thanks for everyone's answer!</p>
  
  <p>I raised the doubt when I noticed that <code>binary.PutUvarint</code> consumes up to 10 bytes to store a large <code>uint64</code>, despite that maximum <code>uint64</code> should only take 8 bytes.</p>
  
  <p>I then found answer to my doubt in the source code of Golang lib:</p>
  
  <pre><code>Design note:
  // At most 10 bytes are needed for 64-bit values. The encoding could
  // be more dense: a full 64-bit value needs an extra byte just to hold bit 63.
  // Instead, the msb of the previous byte could be used to hold bit 63 since we
  // know there can't be more than 64 bits. This is a trivial improvement and
  // would reduce the maximum encoding length to 9 bytes. However, it breaks the
  // invariant that the msb is always the "continuation bit" and thus makes the
  // format incompatible with a varint encoding for larger numbers (say 128-bit).
  </code></pre>