07/10/03 00:27:59
>>641
> [10101010]を右に1ビットシフトした場合
> [10010101]になるか[01010101]になるかは処理系依存
(URLリンク(proger.blog10.fc2.com))
> C言語の規格として、算術シフトか論理シフトかは不定
うそ。規格では次のようになっている。ISO/IEC 9899, 1999 より:
> 6.5.7
> The result of E1 >> E2 is E1 right-shifted E2 bit positions.
> If E1 has an unsigned type or if E1 has a signed type and a
> nonnegative value, the value of the result is the integral
> part of the quotient of E1 / 2^E2. If E1 has a signed type
> and a negative value, the resulting value is implementation-defined.
つまり、E1 が unsigned であるか、もしくは signed かつ E1 ≧ 0 のときに
限って右シフトの動作は定められており、それ以外は implementation-defined。
すなわち、論理シフトやら算術シフトの範囲を超えて処理系の自由。