Reputation: 61473
I am having a tough time googling /=
... can anyone tell me what this code does?
number = digits[n % digits.Length] + number;
n /= digits.Length;
My intent is to determine what the remainder of this operation is... so I know when to stop or keep going.
Upvotes: 3
Views: 7582
Reputation: 13041
Just to add to what has already been posted in various answers, a compound assignment operator $=
(replace $
with a binary operator) is similar to an assignment with the binary operator used in the right-hand side. The difference is that the left-hand side is evaluated only once. So:
x $= y
x
is evaluated only once.
x = x $ y
x
is evaluated twice.
Unlikely to make a difference in practice.
Upvotes: 4
Reputation: 74345
/=
is a division operator.
x /= y ;
is the same thing as saying:
x = x / y ;
Upvotes: 0
Reputation: 29996
Per MSDN, these two are equivalent:
n /= digits.Length;
and
n = n/digits.Length;
Similar to the more commonly seen:
n+=1;
Upvotes: 0
Reputation: 25008
x /= y
means set x equal to (in this case the integral part of) 'x divided by y'
. /
is the division operator.
Upvotes: 1
Reputation: 9356
This is the division assignment operator operator meaning n = n/digits.Length
See MSDN: /= Operator (C# Reference) for details.
Upvotes: 5
Reputation: 2088
Same as
n += 4; // adds 4
n *= 4; // 4 times
just division.
Upvotes: 0