1. Hex to float problem

hai,

I suspect something wrong

i have 32 bit data, its float in hex
if i have 0x00000000 data then it corresponding float value is 0.0 for this i tried like this

Code:
```unsigned char ch[]={0x00,0x00,0x00,0x00};
unsigned long data=0;

while(i<4){
data=data<<8|ch[i];
i++;
}
f=(1-(2*(data>>31)))*pow(2,((data>>23 & 0x0FF) -127))*(1+(float)(data & 0x007FFFFF)/0x800000); // convert hex to float

//successfully converted to float

printf("float value f = %f \n",f);// o/p>> i get  f=0.0

if(f<=0.0)
printf("less than 0r equal to 0 ");

else
printf("greater than 0");```
o/p i get as greater than 0
but when i changed the if(f<=0.0) to if(f<=0.001), i get what i expect. i.e less than 0.

i also tried with if(f<=(float)0.0) the result is same greater than 0.

I wonder what cud be the reason, is OS changing float hex data from 0x00000000 to something else

Any light on this !!!

thanks

2. Why is that strange? I haven't check your code, but you say you get less than 0.001 but not less than 0.0. So the result might be from 0.0 to 0.001.