I have the following code snippet:
#include <stdio.h>
int main(){
printf("%d\r\n", -1 % 7);
return 0;
}
When run, it prints -1
. According to my own math and calculators like this one (http://www.miniwebtool.com/modulo-calculator/?number1=-1&number2=7), my answer should be 6. Im assuming there is some 'gotcha' in the C implementation of modulo that I am not grasping. Can someone explain why I am not getting the answer I expect?