clarification of int & int inside a if statement in C++

This question already has an answer here:

  • Understanding the bitwise AND Operator 4 answers

  • It will result in an entire integer. When you use the bitwise and, each bit of the two values are and'ed together, and each bit in the result is set accordingly. The result will be the same number of bits as the values being and'ed together.

    This is assuming you're using two integer variables.


    Assuming mask is a pointer to an integer type the compiler will do the following:

  • Access the i -th element of the mask "array" as an integer
  • make sure both operands are of the same size (this may involve bit-expansion or truncation)
  • do a bit-wise AND
  • if there was a single bit set in the result from the previous AND operation the value will be treated as true , otherwise as false (if every single bit of the result is 0 )
  • 链接地址: http://www.djcxy.com/p/72642.html

    上一篇: 在C语言中使用&(AND)运算符是什么?

    下一篇: 在C ++中的if语句中澄清int&int