标签: java casting bit-manipulation
无论如何将浮动视为一个int的值(并返回)?像这样:
int myInt = 1729; float myFloat = intToFloatPreservingBitPattern(myInt); int otherInt = floatToIntPreservingBitPattern(myFloat);
(在C ++中我可以使用float myFloat = reinterpreted_cast<float>(myInt),我在Java中寻找类似的东西)
float myFloat = reinterpreted_cast<float>(myInt)
答案 0 :(得分:3)
您正在寻找Float.intBitsToFloat method。
Float.intBitsToFloat
相反的是Float.floatToIntBits method。
Float.floatToIntBits