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

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
4번째 줄: 4번째 줄:


==Bash==
==Bash==
<source lang='Bash'>
<syntaxhighlight lang='Bash'>
echo $(( 7 << 1 ))
echo $(( 7 << 1 ))
# 14
# 14
echo $(( 7 << 2 ))
echo $(( 7 << 2 ))
# 28
# 28
</source>
</syntaxhighlight>


==C==
==C==
<source lang='c'>
<syntaxhighlight lang='c'>
#include<stdio.h>
#include<stdio.h>
int main() {
int main() {
21번째 줄: 21번째 줄:
   printf("%d\n", 7<<4 ); // 112
   printf("%d\n", 7<<4 ); // 112
}
}
</source>
</syntaxhighlight>


==PHP==
==PHP==
<source lang='PHP'>
<syntaxhighlight lang='PHP'>
echo 7 << 1;
echo 7 << 1;
# 14
# 14
echo 7 << 2;
echo 7 << 2;
# 28
# 28
</source>
</syntaxhighlight>


==Python==
==Python==
<source lang='Python'>
<syntaxhighlight lang='Python'>
print 7 << 1
print 7 << 1
# 14
# 14
print 7 << 2
print 7 << 2
# 28
# 28
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

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