"비트연산 shift left"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(사용자 2명의 중간 판 12개는 보이지 않습니다)
1번째 줄: 1번째 줄:
[[category: bitwise]]
==개요==
;비트연산 shift left, left shift
;왼쪽 시프트, 왼쪽 쉬프트, 왼쪽으로 시프트
 
==Bash==
<syntaxhighlight lang='Bash'>
echo $(( 7 << 1 ))
# 14
echo $(( 7 << 2 ))
# 28
</syntaxhighlight>
 
==C==
<syntaxhighlight lang='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
}
</syntaxhighlight>


==PHP==
==PHP==
[[category: PHP]]
<syntaxhighlight lang='PHP'>
<source lang='Python'>
echo 7 << 1;
echo 8 << 1; // 16
# 14
echo 8 << 2; // 32
echo 7 << 2;
</source>
# 28
</syntaxhighlight>


==Python==
==Python==
[[category: Python]]
<syntaxhighlight lang='Python'>
<source lang='Python'>
print 7 << 1
print 8 << 1 # 16
# 14
print 8 << 2 # 32
print 7 << 2
</source>
# 28
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[right shift]]
*[[비트연산 shift right]]
 
[[분류:비트 연산]]
[[분류:Bash]]
[[분류:PHP]]
[[분류:Python]]

2020년 11월 2일 (월) 02:31 기준 최신판

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 }}