Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.
왼쪽 시프트 (<<) 연산자는 첫 번째 피연산자를 명시된 비트 수(32의 나머지)만큼 왼쪽으로 이동합니다. 왼쪽으로 이동된 초과 비트는 폐기됩니다. 오른쪽은 움직인 비트 수 만큼 0비트로 채워집니다.
이 연산자는 첫 번째 피연산자를 명시한 비트 수만큼 왼쪽으로 이동합니다. 왼쪽으로 이동된 초과 비트는 폐기됩니다. 오른쪽은 움직인 비트 수 만큼 0 비트로 채워집니다.
예를 들어, 9 << 2은 36이 도출됩니다.
9 (10진수): 00000000000000000000000000001001 (2진수) -------------------------------- 9 << 2 (10진수): 00000000000000000000000000100100 (2진수) = 36 (10진수)임의의 숫자 x를 왼쪽으로 y비트 단위로 이동하면 x * 2 ** y입니다. 그래서 예를 들어 9 << 3은 9 * (2 ** 3) = 9 * (8) = 72으로 해석됩니다.
왼쪽 피연산자는 32비트 정수로 변환됩니다. 즉, 부동 소수점 숫자는 잘리고 32비트 경계 내에 있지 않은 숫자는 오버플로우/언더플로우됩니다.
오른쪽 피연산자는 부호 없는 32비트 정수로 변환된 다음 32 나머지 연산의 값을 가져오므로 실제 시프트 오프셋은 항상 0에서 31 사이의 양의 정수입니다. 예를 들어, 100 << 32는 100 << 0과 동일(이 결과값은 100입니다)합니다. 32 나머지 연산은 0이기 때문입니다.
| ECMAScript® 2027 Language Specification # sec-left-shift-operator |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025년 2월 11일 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.