开发者

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));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜