I am converting four bytes to float and I'm getting NaN
as a result, but I want the value 0.0
. What am I doing wrong?
This is my code:
public class abc
{
public static void main(String[] args)
{
int[] arry = { 255, 255, 255, 255 };
int num = ((arry[0] << 24) & 0xFF000000) | ((arry[1] << 16) & 0xFF0000)
| ((arry[2] << 8) & 0xFF00) | (arry[3] & 0xFF);
float f = Float.intBitsToFloat(num);
f= (float) ((f < 0 ? Math.ceil(f * 10) : Math.floor(f * 10)) / 10);
System.out.println(f);
}
}