byte a; //a number between 0 and 100byte b;byte c1,c2;c1=a*b/100;c2=byte(word(a)*word(b)/100);
Let's say I have the following code:
Because a is constrained to 0,100, the value of c will between 0 and 255, so it fits in a byte.
If I remember correctly, multiplications are executed before divisions in C
so should I explicitly cast a and b to words
is it necessary to cast a and b to words so that the temporary results a*b doesn't cause overflow?