TCC1.CCA = (x * y) / 100;
In the operation above, x and y are unsigned ints. While in my application the result will always fit into an unsigned int, there are cases where (x * y) > two bytes. In these cases, CCA (which is two bytes) gets loaded with the wrong value. When doing int arithmetic, do all intermediate results have to fit in an int? If so, what's the fix? Parentheses, a cast, ...? Is there another explanation for my CCA problem? Thanks.