Revision: 63864
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 13, 2013 16:19 by ankurtrapasiya
Initial Code
int mod(int x, int m) { return (x%m + m)%m; } int mod(int x, int m) { int r = x%m; return r<0 ? r+m : r; }
Initial URL
Initial Description
-13%2 = -1 so this might cause problem in your program sometime. So always write your code in such a way that it never cause any problem in sleep also.. :) Use anyone of the following code snippet.
Initial Title
Safety for checking MOD for negative values
Initial Tags
Initial Language
Java