title: Binary Representation Issue in MATLAB Using dec2bin
body: <p>I have been dealing with an issue with MATLAB when trying to visualize the binary representation of large integers and it has really confused me. I am working on a little-endian machine and positive <code>int64</code> values. Therefore, the most significant bit (MSB) is always 0. All the other bits can be 0 or 1. I noticed that when I check the binary structure of large values many bits on the least significant bits (LSB) side are 0. For instance:</p>
  <pre><code>&gt;&gt; dec2bin(4611695988848162845, 64)
  
  ans =
  
      '0100000000000000000010010001000101101011011000110111100000000000' % WRONG!     
  &gt;&gt; dec2bin(4611695988848162846, 64)
  
  ans =
  
      '0100000000000000000010010001000101101011011000110111100000000000' % &lt;--- WRONG and identical to above!
  </code></pre>
  <p>While the correct binary representation of value 4611695988848162845 should be:</p>
  <pre><code>Correct binary representation of 4611695988848162845:
  '0100000000000000000010010001000101101011011000110111100000011101'
  </code></pre>
  <p>You can verify the correct binary structure <a href="https://www.rapidtables.com/convert/number/decimal-to-binary.html" rel="nofollow noreferrer">here</a> or use a <a href="https://stackoverflow.com/a/7349767/7852589">simple C++ code</a> to verify this. Can someone please explain to me what happens here? Doing <code>dec2bin(int64(4611695988848162845), 64)</code> does not seem to help either.</p>