Is (a - b) mod m same as ((a mod m) - (b mod m)) mod m?I'm having hard time dealing with it.Also if (a mod m) < (b mod m) then answer should be ((a mod m) - (b mod m) + m) mod m? I tried using library function fmodl but it also giving negative answers.Also if I use unsigned numbers then output is something different.
So what is the correct way to calculate (a-b) mod m where a>=b>=m in C++.