问题描述
我的问题使用Java作为一个例子,但我想它适用于所有可能
My question uses Java as an example, but I guess it applies to probably all.
有没有和XOR运算符(^在Java)之间的实际差异不等于-TO(!=在Java),比较布尔值当?
Is there any practical difference between the XOR operator ( ^ in java) and the NOT-EQUAL-TO ( != in java), when comparing booleans?
我在这里评价的东西,但我一直在想(似乎不可思议,两件事情相等)......并没有在网络上找到任何东西。在一些论坛上很快结束,没有任何结果只是一个讨论。
I evaluated things here, but I just kept wondering (seems weird, two things equal)... and didn't find anything on the net. Just one discussion in some forum that ended quickly without any result.
推荐答案
有关布尔值,它们指的是同样的事情 - 虽然有一个复合赋值操作符的XOR:
For Boolean values, they mean the same thing - although there's a compound assignment operator for XOR:
x ^= y;
有对不平等没有等价复合赋值操作符。
There's no equivalent compound assignment operator for inequality.
至于为什么他们都可以 - 这将是奇怪的XOR的不的可用只是因为它的工作方式是相同的不平等。它理应在那里,所以它是。对于非布尔类型的结果是不同的,因为它是一个不同的结果类型,但是这并不意味着它是有意义的去除异或布尔
。
As for why they're both available - it would be odd for XOR not to be available just because it works the same way as inequality. It should logically be there, so it is. For non-Boolean types the result is different because it's a different result type, but that doesn't mean it would make sense to remove XOR for boolean
.
这篇关于什么是XOR和不等于-TO的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!