fork download
  1.  
  2. class Main
  3. {
  4. public static void main (String[] args) throws java.lang.Exception
  5. {
  6. byte b1 = (byte) -32;
  7. String s1 = String.format("%8s", Integer.toBinaryString(b1 & 0xFF)).replace(' ', '0');
  8. System.out.println(s1); // 10000001
  9.  
  10. byte b2 = (byte) -56;
  11. String s2 = String.format("%8s", Integer.toBinaryString(b2 & 0xFF)).replace(' ', '0');
  12. System.out.println(s2); // 00000010
  13. }
  14. }
Success #stdin #stdout 0.08s 53932KB
stdin
Standard input is empty
stdout
11100000
11001000