Working with floats is very fuzzy. For example a float with value 123.456 can be stored in memory like 123.4559999998. That's the reason why you should never compare floats. You can get the same problem when trying to convert a float to an integer the way you want to do it.
Here is a small example, but it's very messy and it doesn't always work.
It works fine when I convert the number 123456001, but when I try 123.45601, the result is: 123.456009.
Code:
#include <string.h>
int main ()
{
float a = 123.456001;
int result = 0;
char buf[40];
char *ptr;
/* copy float number to string (is it %f ???, not sure) */
sprintf(buf, "%f", a);
/* find the dot */
if((ptr = strchr(buf, '.')) == NULL) return -1;
/* remove the dot */
for(; *ptr != '\0'; ptr++) *ptr = *(ptr+1);
/* remove trailing zero's */
for(ptr-=2; *ptr == '0'; ptr--) *ptr = 0;
/* copy string to integer (can also use atoi) */
sscanf(buf, "%d", &result);
printf("%d\n", result);
return 0;
}