Print an unsigned byte in Java

Use Byte.toUnsignedInt and print the resulting int:

byte b = (byte) 0b10010110; // -106 signed, or 150 unsigned

System.out.println("Value of my unsigned byte: " + Byte.toUnsignedInt(b));  // 150

Comments

Be the first to comment!