View Single Post
Posts: 9 | Thanked: 0 times | Joined on Apr 2006
#63
Gnuite :

This is the code I have added at your sources :

static gfloat strtofloat(gchar *num)
/* Function to convert string to float number
***Note I have no check for errors in string***
*/
{
gfloat ret = 0.f;
gchar *pchar;
gfloat n;
gfloat dec = 0.f;

pchar = num;
while(*pchar != '\0' && *pchar !=' ') {
if (*pchar == '.')
dec = 10.f;
else {
if (dec) {
n = ((gfloat) (*pchar - '0')) / dec;
dec *= 10.f;
}
else {
n = (gfloat) (*pchar - '0');
ret *= 10.f;
}

ret += n;
}
pchar++;
}

return(ret);
}
and I have changed all references to 'atof' for 'strtofloat'.

Great code, great work, I have no problems to follow it.

Thanks. Demostenes.

Last edited by Demostenes; 2006-05-13 at 13:12.