XORing two doubles in Java
How to XOR two doubles in JAVA?
simple '^' doesn't work for doubles... Would 开发者_StackOverflow中文版I have to convert a double to binary form and do it bitwise? or is there any other way?
If you mean to do this bitwise you need to use the Double
utility functions to get long
representations and then convert back to a double at the end:
double c = Double.longBitsToDouble(
Double.doubleToRawLongBits(a) ^ Double.doubleToRawLongBits(b));
精彩评论