There is XOR function in Java - a^b
Java中有XOR函数 - a ^ b
For exemple: 5^3 = 6
例如:5 ^ 3 = 6
Can you tell me inverse function? If I have 6
and 3
can i get range of numbers which include number 5
?
你能告诉我反函数吗?如果我有6和3可以获得包括数字5的数字范围?
2 个解决方案
#1
108
The inverse is XOR!
逆是异或!
If you have:
如果你有:
c = a^b;
You can get a
or b
back if you have the other value available:
如果您有其他可用值,您可以获得a或b返回:
a = c^b; // or b^c (order is not important)
b = c^a; // or a^c
For example if a = 5
, b = 3
(and thus c = 6
as you mentioned) you get:
例如,如果a = 5,b = 3(因此你提到的c = 6),你得到:
b=0011 (3) a=0101 (5)
c=0110 (6) XOR or c=0110 (6) XOR
---------- ----------
a=0101 (5) b=0011 (3)
#2
25
The inverse of XOR is XOR.....
XOR的反转是XOR .....
#1
108
The inverse is XOR!
逆是异或!
If you have:
如果你有:
c = a^b;
You can get a
or b
back if you have the other value available:
如果您有其他可用值,您可以获得a或b返回:
a = c^b; // or b^c (order is not important)
b = c^a; // or a^c
For example if a = 5
, b = 3
(and thus c = 6
as you mentioned) you get:
例如,如果a = 5,b = 3(因此你提到的c = 6),你得到:
b=0011 (3) a=0101 (5)
c=0110 (6) XOR or c=0110 (6) XOR
---------- ----------
a=0101 (5) b=0011 (3)
#2
25
The inverse of XOR is XOR.....
XOR的反转是XOR .....