I use this, it's from the Dx11 spec for repeat-texture addressing.
public static int Modulo(int x, int y) { x= x % y; return x >= 0 ? x : x + y; }