本文介绍了XOR的反函数是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Java中有XOR函数 - a ^ b
There is XOR function in Java - a^b
例如: 5 ^ 3 = 6
你能告诉我反函数吗?如果我有 6
和 3
我可以获得包含数字 5的数字范围
?
Can you tell me inverse function? If I have 6
and 3
can i get range of numbers which include number 5
?
推荐答案
逆是异或!
如果您有:
c = a^b;
您可以获得 a
或 b
如果您有其他可用值,则返回:
You can get a
or b
back if you have the other value available:
a = c^b; // or b^c (order is not important)
b = c^a; // or a^c
例如,如果 a = 5 ,
b = 3
(因此 c = 6
):
For example if
a = 5
, b = 3
(and thus c = 6
as you mentioned) you get:
b=0011 (3) a=0101 (5)
c=0110 (6) XOR or c=0110 (6) XOR
---------- ----------
a=0101 (5) b=0011 (3)
这篇关于XOR的反函数是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!