Hello there,
I am having some strange results when trying to compute a simple math calculation. Can anyone please have a look at this code?
digitos[], i and v_digito are int types. pow is:Code:for (i=N_DISPLAY-1 ; i>=0 ; i--)
{
digitos[i] = v_digito/(int)pow(10, (double)i);
v_digito = v_digito - digitos[i]*(int)pow(10, (double)i);
}
double pow (double a, double b);
What I am trying to do is to extract each of the algarisms of a number.
Debuging I found out the firs expression seens to be Ok, but the second simple ads 1 or 2 to the desired number to be stored at v_digito.
I suspect it is a casting problem as when I "play" with then I get diferent results, but none good..
Can anyone help? Thank you!