Hi I'm aware in C
the modulo
of a negative dividend results in a negative modulo, but what I found is that the modulo of a negative dividend using a long unsigned divisor or a long long unsigned divisor results in a positive modulo!
Here's an example:
#include <stdio.h>
int main(int argc, char** argv)
{
long long int a = -2205348223670655684LL;
printf("%lld %lld %lld %lld %lld %lld\n", a % 20, a % 20L, a % 20LL, a % 20U, a % 20LU, a % 20LLU);
return 0;
}
and the output:
$> ./a.out -4 -4 -4 -4 12 12
Can anyone explain why? I've tried it with GCC 4.8 and 5.1