fork download
  1. #include <stdio.h>
  2.  
  3. int mod_256(int x)
  4. {
  5. return (int)(unsigned char)x;
  6. }
  7.  
  8. int main()
  9. {
  10. printf("expected : %d\n", -1 % 256);
  11. printf("actual : %d\n", mod_256(-1));
  12. return 0;
  13. }
  14.  
Success #stdin #stdout 0s 4548KB
stdin
Standard input is empty
stdout
expected : -1
actual : 255