floating point problem

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;
        
}
#include <stdio.h>

int main()
{
  int i;
  float f=1.0;

  for( i=0; i<9; i++, f /= 10 ) {
    printf("%10.8f\n", f);
  }
  return 0;
}

Two things:

floating point numbers do not always represent a given number exactly - which you are encountering - the 0.0099998 result from division.

limits.h defines the limit of precision for each datatype, and the smallest number that can be represented. Implementations vary. FLT_DIG - the number of significant digits in a float is defined to be at least 6 for POSIX, FLT_MIN <= 10^-38.

this might interest you,

check this out

In memory floating point numbers (and other internal numbers excluding special cases like BCD) are stored in binary format (e.g. in Intel reverse order for integers on PC platforms), so 0.1, 0.01, ... cannot be represented exactly, only division by 2^x (not by 10 or any other number) can give you an exact number.