I'm getting the IEEE754 formatted float value in two integer variables. The integers are 13107 & 17184. The integers are needed to be swapped. Now, how can i extract the float value from these two integers ?. The float value for these integers will be equals to 160.19 (approx.). My code provides a result of 1.1 only ..
int buffer = 0;
int float_value = 0;
float result = 0;
float value = 0, mantissa = 0;
if (swap == FALSE) {
float_value = rec_buf;
float_value = float_value << 16;
buffer = rec_buf1;
float_value = (float_value | buffer);
}else{
buffer = rec_buf1;
float_value = rec_buf;
float_value = float_value << 16;
float_value = (float_value | buffer);
}
String a = Integer.toBinaryString((int)float_value);
value = Float.valueOf(a);
anyone help me out with this issue
If you have the 32-bit IEEE-754 representation of a float
in an int
, you can convert back to float
using Float.intBitsToFloat
.