[英]XORing two doubles in Java
How to XOR two doubles in JAVA? 如何在JAVA中对两个双打异或?
simple '^' doesn't work for doubles... Would 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
实用程序函数来获取long
表示,然后在最后转换回double:
double c = Double.longBitsToDouble(
Double.doubleToRawLongBits(a) ^ Double.doubleToRawLongBits(b));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.