본문 바로가기

Java

Bit 연산

- http://forum.falinux.com/zbxe/index.php?document_srl=580758&mid=lecture_tip


public class BitTest {

@Test

public void testLeftShift() throws Exception {

int sut = 0x1;

System.out.println(sut); //1

sut = 0x1 << 3; // 3bit이동을 의미 0001 -> 1000(2*3)

System.out.println(sut);

sut = 0x2 << 3; // 3bit (00010 -> 10000 = 16)

System.out.println(sut);

}

}