IT/Java
비트연산자 활용1
알라이또
2017. 1. 21. 11:45
반응형
public class BitTest {public static void main(String[] args) {short pos = (7<<8) | 5; // x=7(0111) / y=5(0101)// pos => 0000 0111 0000 0101int x = (pos>>>8);int y = 0x00ff & pos; // 255 & posSystem.out.printf("x : %d ",x);System.out.printf("y : %d",y);}}<실행결과>x : 7 y : 5