What's the result of a & b?

后端 未结 4 595
北恋
北恋 2020-12-08 18:38

This is awkward, but the bitwise AND operator is defined in the C++ standard as follows (emphasis mine).

The usual arithmetic conversions are performe

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-08 19:42

    Legally, we could consider all bitwise operations to have undefined behaviour as they are not actually defined.

    More reasonably, we are expected to apply common sense and refer to the common meanings of these operations, applying them to the bits of the operands (hence the term "bitwise").

    But nothing actually states that. Shame my answer can't be considered normative wording.

提交回复
热议问题