In C the following code ...
#include<stdio.h>
#include<string.h>
#include<stdbool.h>
#include<stdlib.h>
int main() {
int result = (-12) % (10);
printf("-12 mod 10 = %d\n",result);
return 0;
}
gives this output
> gcc modTest.c
> ./a.out
-12 mod 10 = -2
But according to this mod calculator -12 mod 10 = 8
In Python ...
> python
Python 3.3.0 (default, Mar 26 2013, 09:56:30)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> (-12) % (10)
8
What is going on in C that produces -2 instead of 8?