I'm reading the specification on bitwise shift operators, and I'm unsure whether integers are ever required to be two's complements.
In NumberBitwiseOp
, it's explicitly mentioned that
Let lbits be the 32-bit two's complement bit string representing ℝ(lnum).
Which probably means that for &
, |
, and ^
, I can confidently say that the operation is working on 32-bit two's complements.
In BigInt::leftShift
, it's mentioned that
Semantics here should be equivalent to a bitwise shift, treating the BigInt as an infinite length string of binary two's complement digits.
Which implies that bitwise shift should operate on two's complements.
However, in Number::leftShift
, it's only mentioned that
Return the result of left shifting lnum by shiftCount bits.
Where lnum is the result of ToInt32
, the latter of which is defined by the mathematical value, not by its binary encoding. Unlike NumberBitwiseOp
, the operation here is working on a number, not a bit string, and the encoding is not specified. The next sentence says " The mathematical value of the result is exactly representable as a 32-bit two's complement bit string", but that sounds like an invariant assertion instead of a normative specification.
Is that an editorial mistake, or have I overlooked something? Does "left shift" necessarily imply "two's complement"?