Hi,
while wondering how unsigned integer division is implemented in C
I found a bug in V7: a/b and a%b with b >= 2^15 does not give the expected
results, if a and b are unsigned int's.
Was this bug ever noticed or even fixed?
Greetings,
Wolfgang
Here is a program showing the bug:
main()
{
unsigned int a, b;
a = 60000;
b = 40000;
printf("a/b: %u, a%%b: %u\n", a/b, a%b);
b = 25000;
printf("a/b: %u, a%%b: %u\n", a/b, a%b);
}
The above program prints
a/b: 65534, a%b: 8928
a/b: 2, a%b: 10000
The first line should be of course
a/b: 1, a%b: 20000