문제

Is there anyway to treat as a float an int's value (and back)? Like this:

int myInt = 1729;
float myFloat = intToFloatPreservingBitPattern(myInt);
int otherInt = floatToIntPreservingBitPattern(myFloat);

(in C++ I could use float myFloat = reinterpreted_cast<float>(myInt), I'm looking for something similar in Java)

도움이 되었습니까?

해결책

You're looking for the Float.intBitsToFloat method.

The reverse is the Float.floatToIntBits method.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top