( (a%m)+(b%m) )%m; // if say, x
( ( ( (a%m)+(b%m) )%m )+m)%m; // then (x+m) % m
Like the second formula is more general than 1st one can you please provide more general form for following (div / sub) :
// for SUB
((a%m)-(b%m)+m)%m;
// for DIV
((a%m)*( B %m))%m; // B is mult. inverse