哪些|和用来^运营商? [英] What are the | and ^ operators used for?

查看:151
本文介绍了哪些|和用来^运营商?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  

可能重复:
  什么是位运算符?

最近我碰到所用的几样|和^运算符。我猜这些都是否定运营商。

那么究竟是什么做的这些运营商代表?

解决方案

如果您将它应用到整数类型,它们是按位或和异或运算符。 但是,如果你把它们应用到布尔类型,它们是逻辑或和异。 看看或操作员的解释和 XOR运算符

您可以从维基百科真值表

Possible Duplicate:
What are bitwise operators?

Recently I came across a few samples that used the | and ^ operator. I am guessing these are or and negation operators.

So what actually do these operators stands for?

解决方案

If you apply it to integral types, they are bitwise or and xor operator. However if you apply them to boolean types, they are logical or and xor. Look at an explanation of or operator and xor operator

You can get more details on boolean operations from the wikipedia truth table

这篇关于哪些|和用来^运营商?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆