0

Just recently I stumbled upon a problem using the (what I assumed to be modulo) operator %:

enter image description here

Basically (-1) % 5 returns -1 instead of 4, so % seems to return the remainder instead of the mathematically correct modulus (either that or Wolfram Alpha is bad at math).

My question is quite simple: Is there a real modulo operator in C# that I don't know of? Or do I have to write my own code for that?

All results I can find in the internet only point to the % ...

4

1 Answer 1

3

There is no modulo operator in c#.

The % operator, is the remainder operator:https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/arithmetic-operators#remainder-operator-

The remainder operator % computes the remainder after dividing its left-hand operand by its right-hand operand.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.