What does the %=
operator do, as shown in this example:
if (a > b)
a %= b;
What are its uses and is it commonly used?
From MSDN:
The % operator computes the remainder after dividing its first operand by its second. All numeric types have predefined remainder operators.
So in your case, the following string
a %= b;
is the same as this one:
a = a % b;
Which also applies to all operators:
a += b
equals to a = a + b
a /= b
equals to a = a / b
a -= b
equals to a = a - b
etc.
It's a shortcut for
a = a % b;
which gets the remainder of a
and b
and stores the result in a
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With