View Full Version : +=??
chrisCPO
04-10-2012, 01:29 AM
sorry guys easy question here what is this +=, what does this do and what is its name in programming so i find what the other ones like it do *= /= -= ...
Master Kenth
04-10-2012, 02:09 AM
+= increments variables by the given number. Say you have a variable X that is 4,
X = 4
X += 2
X is now 6.
The other ones are just different math operators, i.e.
*= is multiplication
/= is division
-= is subtraction
Crusha K. Rool
04-10-2012, 02:17 AM
X += Y and the others are just a shorter form of writing
X = X + Y
If you only need to increment by 1 each time, you can use X++ as opposed to X = X + 1.
In C are those shortcuts also better for the performance (if the compiler is halfway decent) because it can tell the CPU that it only needs to look up X once and not twice. But I don't know if the UnrealScript compiler/interpreter makes use of such kind of optimization.
A.M.M.D.
04-10-2012, 11:23 AM
x+=2 is simply short for x=x+2
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.