I am having problem with Float.intBitsToFloat
in
Programming Questions
•
1 years ago
Hi all
I am trying to convert 4 bytes into a float number. I was looking into Float.intBitsToFloat but I am stock at it. I have a byte[] data={ byte(154), byte(105), byte(19), byte(64)}; the float read out of this 4 bytes should be 2.3033204, when I put the byte manually it works fine:
I am trying to convert 4 bytes into a float number. I was looking into Float.intBitsToFloat but I am stock at it. I have a byte[] data={ byte(154), byte(105), byte(19), byte(64)}; the float read out of this 4 bytes should be 2.3033204, when I put the byte manually it works fine:
Float.intBitsToFloat(0x4013699A) gives me 2.3033204
However, when I try to do it dynamic in the following way, it doesn't work correctly anymore. please help!
Float.intBitsToFloat( (data[3]>>24)|(data[2]>>16)|(data[1]>>8)|data[0]) this gives me NaN...
What might be the problem!?
Kyle
2