美文网首页
Difference between bitwise and l

Difference between bitwise and l

作者: 宣雄民 | 来源:发表于2019-04-12 13:41 被阅读0次
image.png
  • As the image depicted above, logical and bitwise operators are used in different scene with some common features.
  • To distinguish the similarities and differences does matter for better programming.
  • For example a logical operator and is represented as && whereas a bitwise operator is represented as &.

  1. A logical operator expects its operands to be boolean expressions(1 or 0) and return a boolean value.
  2. A bitwise operator works on integral(short, int, unsigned, char, bool, long, unsigned char, etc..)values and return integral value.

#include <stdio.h>

int main(int argc, char* argv[])
{
        int x = 10;
        int y = 11;

        if (y > 1 && y > x)
        {
                printf("y is greater than 1 AND x\n");
        }

        int z = x & y;
        printf("z-> x bitwise(AND) y \n%d", z);

        printf("\n");

        return 0;
}
~   

相关文章

网友评论

      本文标题:Difference between bitwise and l

      本文链接:https://www.haomeiwen.com/subject/vhhcwqtx.html