I'm a bit confused with modulo in c. Trying the following examples:
double d = 4912;
int a;
a = (int) d%100;
printf ("%d \n", a);
Answer is 12. Fine, that's what I'm expecting. Now I try this:
double d = 49.12;
d = d*100;
int a;
a = (int) d%100;
printf ("%d \n", a);
Answer: 12. Again what I'm expecting. But now:
double d = 49.12;
int a;
a = (int)(d*100)%100;
printf ("%d \n", a);
Answer: 11! That's definitly not what I expected. But I have no idea why. oO