Increment and decrement operators

With the gradual increase or decrease in size or variable, the increment is (from Latin incrementare: larger) or decrement ( decrementare Latin: reduce ) the amount fixed by the change. An example is a counter in a hub, which increases its value by 1 on each pass. Application will find the terms, especially in computer science.

Computer science

Increment or decrement are basic operations that are carried out usually at the machine level through a single command. The construction of loops often based on the increment or decrement a variable. In the most common case, the amount of the increment or decrement is 1

Implementation in various programming languages

Often, the increment or decrement operation is defined only for integer variables, sometimes for enumeration types (example: weekdays ). In the Perl programming language, you can apply the operation on strings.

Although in many programming languages ​​an increment operation is implemented with a machine instruction that is not the case everywhere. In Java, for example, an increment or decrement a variable of a primitive data type is not atomic, which means that even this operation is divided into several (machine ) instructions on the Java Bytecodeebene.

Kodebeispiele

I and j denote variables here.

In Perl, PHP and the majority of other advanced programming languages ​​, in the same way as in C and decremented with the difference that scalar variables are identified by the prefix $.

Value assignment time in higher-level expressions

If an increment or decrement operation in a statement within another expression used, it must be distinguished whether the value increase or decrease takes place before or after the evaluation of the parent expression.

Int i = 5; int c = i ; / / C = 5 preincrement Previous appreciation int i = 5; int d = i; / / D = 6 decrement Postdekrement Nachherige value reduction. int i = 5; int e = i -; / / E = 5 Prädekrement Previous value reduction int i = 5; int f = - i; / / F = 4

Economics

In economics, the increment is the specified minimum increase your bid at auctions.

Digital Sensor Technology

In the digital measurement technique, where the quantity to be measured is divided into discrete values ​​, the increment of the measured quantum, the smallest possible increment.

Plotter

For plotters and other drafting machines, the increment is the smallest possible increment of the solid characters head. A line or curve is divided into equal increments.

20555
de