J
Joachim Schmitz
Chuck wrote "for unsigned x"Philip said:CBFalconer said:Robert said:dspfun wrote:
These operators yield values that depend on the internal
representations of [unsigned] integers
Question is: Is --for instance-- (x << 2) == (x * 2) guaranteed?
I thought so.
It is guaranteed to be false.
Not so. x == -1 produces UB in the LH operand, so it could be true.
Slightly more plausibly, if x == 0 then the expression is guaranteed
to be true.
Again, not so. For x == -1, no overflow occurs but UB does occur so noHowever, barring arithmetic
overflow, ((x << 2) == (x * 4)) is guaranteed for unsigned x.
guarantees exist.
Bye, Jojo