비트연산 shift left

Jmnote (토론 | 기여)님의 2019년 2월 5일 (화) 03:58 판 (→‎PHP)

1 개요

비트연산 shift left, left shift
왼쪽 시프트, 왼쪽 쉬프트, 왼쪽으로 시프트

2 Bash

echo $(( 7 << 1 ))
# 14
echo $(( 7 << 2 ))
# 28

3 C

#include<stdio.h>
int main() {
   printf("%d\n", 7<<0 ); // 7
   printf("%d\n", 7<<1 ); // 14
   printf("%d\n", 7<<2 ); // 28
   printf("%d\n", 7<<3 ); // 56
   printf("%d\n", 7<<4 ); // 112
}

4 PHP

echo 7 << 1;
# 14
echo 7 << 2;
# 28

5 Python

print 7 << 1
# 14
print 7 << 2
# 28

6 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}