Hi all!
Hi all!
I am working with a problem to find the smallest floating point number that can be represented.
I am going in a loop ,stating with an initial value of 1.0 and then diving it by 10 each time thru the loop.
So the first time I am getting o.1 which I wanted.But from the next iteration I am getting 0.0099998.But this is not I want.
I want a result like this.First time I am 0.1.
Then next iteration should give me 0.01.
Next iteration should give me 0.001 and so on.
I don't know how to achieve this ..I am posting a piece of code here for u to look.
Please suggest.Thanks in advance.
for(;;)
{
i=i*10;
small=(1.0)/i; /*here I am getting 0.0099998 on the second iteration. I need 0.01 on 2nd iteration
and 3rd iteration should be 0.001etc.*/
ip=(int*)&small;
sprintf(sztemp,"%08x",*ip);
if(strcmp(sztemp,szSmall)==0) break;
}