fork(1) download
  1. class Ideone {
  2. public static int convert(byte b1, byte b2) {
  3. int i1 = (int) (((b2 << 8) + (b1 & 0xFF)) & 0x0000FFFF);
  4. short s1 = (short) i1;
  5. int i2 = (int) s1;
  6. return i2;
  7. }
  8.  
  9. public static int convertEquivalent(byte b1, byte b2) {
  10. return (short) ((b2 << 8) | (b1 & 0xFF));
  11. }
  12.  
  13. public static void main(String[] args) throws java.lang.Exception {
  14. byte b1 = Byte.MIN_VALUE;
  15. do {
  16. byte b2 = Byte.MIN_VALUE;
  17. do {
  18. if (convert(b1, b2) != convertEquivalent(b1, b2)) throw new AssertionError();
  19. } while (b2++ != Byte.MAX_VALUE);
  20. } while (b1++ != Byte.MAX_VALUE);
  21. }
  22. }
  23.  
Success #stdin #stdout 0.1s 27704KB
stdin
Standard input is empty
stdout
Standard output is empty