^(XOR)运算符的作用是什么? [英] What does the ^ (XOR) operator do?
本文介绍了^(XOR)运算符的作用是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
异或执行什么数学运算?
What mathematical operation does XOR perform?
推荐答案
XOR是一个二进制运算,表示异或",也就是说,如果仅精确地 one ,结果位将为1.设置了em>.
XOR is a binary operation, it stands for "exclusive or", that is to say the resulting bit evaluates to one if only exactly one of the bits is set.
这是它的功能表:
a | b | a ^ b
--|---|------
0 | 0 | 0
0 | 1 | 1
1 | 0 | 1
1 | 1 | 0
此操作在数字的每两个对应位之间执行.
This operation is performed between every two corresponding bits of a number.
示例:7 ^ 10
二进制形式:0111 ^ 1010
Example: 7 ^ 10
In binary: 0111 ^ 1010
0111
^ 1010
======
1101 = 13
属性:该运算是可交换的,关联的并且是自反的.
Properties: The operation is commutative, associative and self-inverse.
它也与加模2相同.
这篇关于^(XOR)运算符的作用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文