Google
 
   
Login
Username:

Password:


Lost Password?

Register now!
Search
Main Menu
top books
Polls
What do you think about php-deluxe.net?
Excellent!
Cool
Hmm..not bad
What the hell is this?
encyclopedia
recommendation
compare webbrowser
Freenet DSL
Who's Online
11 user(s) are online (10 user(s) are browsing encyclopedia)

Members: 0
Guests: 11

more...
browser tip
Unix Befehle
manual of unix befehle
recommendation!
Sponsored
partner

Augmented assignment

Augmented assignment is the name given to certain operator (programming)s in certain programming languages (especially those derived from C programming language). An augmented assignment is generally used to replace a statement where an operator takes a Variable as one of its arguments and then assigns the result back to the same variable.

For example, the following statement or some variation of it can be found in many programs:

x = x + 1

This means find the number stored in the variable x , add 1 to it, and store the result of the addition in the variable x . As simple as this seems, it may have an inefficiency, in that the location of variable x has to be looked up twice if the compiler does not recognize that two parts of the expression are identical. In comparison, here is the augmented assignment version:

x += 1

This version looks up the location of variable x just once, and modifies it in place.

In general, most operators that can take a variable as one of their arguments and return a result of the same type have an augmented assignment equivalent that assigns the result back to the variable in place, including arithmetic operators, bitshift operators, and bitwise operation.