Quote:You may also change/add the commented lines below,so that you could support also negative values:
The idea is simply by not touching the great short code CPallini made for positive values and just treat the negative value as positive and multiplying by -1 at the end to make it negative.
char inputstr = "-.45";
float result= 0.0f;
int len = sizeof(inputstr)-1;
for (; n < len; ++n)
if (inputstr[n] == '.')
dotpos = len - n - 1;
result = result * 10.0f + (inputstr[n]-'0');
result /= 10.0f;
I have changed size_t to integer,because I don't know how to use them.