title: Howto print Long in Binary?
body: <p>I am trying to print a Long in Binary, but it keeps cutting off <code>0</code>'s. Is there a way to force it to show all bits?</p>
  
  <p>This is my code:</p>
  
  <pre><code>long l = 1;
  System.out.println(Long.toBinaryString((long)l));
  </code></pre>
  
  <p>Returns as mentioned only <code>1</code> due to removed <code>0</code>'s i wish to maintain:</p>
  
  <p><code>0000 0000 0000 0000 0000 0000 0000 0001</code></p>
  
  <p>Thanks in advance.</p>
  
  <p>My temporary nasty solution:</p>
  
  <pre><code>public String fillZeros(Long value) 
  {
      String str = Long.toBinaryString((long) value);
      String temp;
      temp = str;
      while(temp.length() &lt; 32) {
          temp = "0" + temp;
      }
      return temp;
  }
  </code></pre>