Re:C-based Virtual Machine for Notch's DCPU-16
by Triave on Wednesday April 04, 2012 @04:50PM
(#3799765)
Depends how left shift is implemented: on some processors (including x86), only the lowest order bits of the number of positions to shift by are used. In Java:
char A = 1;
A = ((char) ((A << 32) & 0xFFFF));
System.out.println(Integer.toHexString(A));
char A = 1; A = ((char) ((A << 32) & 0xFFFF)); System.out.println(Integer.toHexString(A));
actually outputs 1.