그냥.. 갑자기 궁금증이 생겨서 해봤는데요..
lhs << rhs 했을 경우에, rhs의 값이 lhs의 비트수보다 클 경우에 rhs%(lhs의 비트수) 의 값만큼 shift가 되더군요..
그런데, 이게 표준에 있는 행동인가요? 아님 gcc에서만 그렇게 동작하는 건가요? ^^
C99 6.5.7.3 에서
If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined.
C++98 5.8.1 에서
The behavior is undefined if the right operand is negative, or greater than or equal to the length in bits of the promoted left operand.
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
Re: 씨언어어서 lhs << rhs 했을때, rhs의 값이 lhs의 비
C99 6.5.7.3 에서
C++98 5.8.1 에서
댓글 달기