I'm trying to get % result of ( -1%26 ) the result should be 25 in python it's right but C# gives -1 as result why and how to get 25 in C# not -1
Asked
Active
Viewed 60 times
1 Answers
1
You can use a different kind of modulus function, like this:
int Modulus(int a, int b) {
return ((a % b) + b) % b;
}
Console.WriteLine(Modulus(-1, 26)); // prints 25

Asaf Hayoun
- 46
- 4