A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Joined: Feb 26, 2001
Jul 09, 2001 10:10:00
I know the mod operator is %, but what does the %= do? Thanks for any help.
Joined: Sep 29, 2000
Jul 09, 2001 10:50:00
a %= b is the same as
a = a % b;
where you stuff the result back into the a value that you started with.
"JavaRanch, where the deer and the Certified play" - David O'Meara
Joined: Oct 18, 2000
Jul 09, 2001 11:25:00
Works just like '+=', '-=', and all the other math shortcut operators...
someNum = someNum % 5; someNum %= 5;
Both have the same effect... they assign the modulus of someNum and 5 to someNum...
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
subject: %= operator?
can any one explain this
Iterations - finding the same value for 2 variables
Picking variables with a given propability
convert Postiive number to negative..
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014