자격증/전자계산기 조직응용기사

자바(JAVA)에서 <<< 가 없는 이유: <<랑 기능이 같아서이다.

공시탈출넘버원 2023. 9. 18. 20:03

자바에는 <<, >> 와 >>>의 3가지 shift 연산자가 있다.

부등호 개수 명칭  
2 arithmetic(signed) L/R shift
산술 시프트
MSB를 제외한 나머지만 시프트
3 logical(unsigned) R shift
논리 시프트
MSB까지도 같이 시프트

 

보통 대응하는 개념이 존재하는데 어째서 <<<, logical(unsigned) L shift는 없는지 궁금해서 찾아보았다.

이유는 <<랑 기능이 같아서이다.

 

Wikipedia 'Arithmeitc shift'

 

출처

https://stackoverflow.com/questions/15318617/why-java-doesnt-support-operator

https://stackoverflow.com/questions/26151644/why-is-there-no-unsigned-left-shift-operator-in-java