# Arithmetic Operators

The Privilege Management for Unix and Linux Security Policy Scripting Language supports the arithmetic operators shown in the following table.

 Operator Description ++ Prefix autoincrement -- Prefix autodecrement ++ Postfix autoincrement -- Postfix autodecrement * Multiplication / Division % Modulus + Addition - Subtraction += Addition self assignment -= Subtraction self assignment *= Multiplication self assignment /= Division self assignment %= Modulus self assignment

The subtraction, addition, multiplication and division operators perform arithmetic operations. The default evaluation order for arithmetic operators is:

• Multiplication, division, and modulus division, left to right
• Addition and subtraction, left to right
`result = 6 * 4 / 2 - 4 + 2;`

result contains the integer value 10.

Prefix Autoincrement Operator

The prefix autoincrement operator (++) adds one to a variable and returns the result.

```a = 3;
b = ++a;```

In this example, both a and b are equal to 4.

Prefix Autodecrement Operator

The prefix autodecrement operator (--) subtracts one from a variable and returns the result.

```a = 3;
b = --a;```

In this example, both a and b are equal to 2.

Postfix Autoincrement Operator

The postfix autoincrement operator (++) returns the value of a variable and adds one to the variable.

```a = 3;
b = a++;```

In this example, a is equal to 4 and b is equal to 3.

Postfix Autodecrement Operator

The postfix autodecrement operator (--) returns the value of a variable and subtracts one from the variable.

```a = 3;
b = a--;```

In this example, a is equal to 2 and b is equal to 3.

`result = 5 + 3;`

Subtraction Operator

The subtraction operator ( - ) subtracts two numbers.

`result = 5 - 3;`

Multiplication Operator

The multiplication operator ( * ) multiplies two numbers.

`result = 5 * 3;`

Division Operator

The division operator ( / ) divides two numbers.

`result = 5 / 3;`

Modulus Operator

The modulus operator ( % ) returns the remainder of integer division.

`result = 5 % 3;`

In this example, result contains the integer value 2. Dividing 5 by 3 yields a result of 1 and a remainder of 2. The reminder portion of the answer, in this case 2, becomes the result of the modulus division operation.

The addition self-assignment operator (+=) adds a value to a variable and stores the result in the variable.

`a += 3;`

In this example, 3 is added to a and the result is stored in a.

Subtraction Self-assignment Operator

The subtraction self-assignment operator (-=) subtracts a value from a variable and stores the result in the variable.

`a -= 4;`

In this example, 4 is subtracted from a and the result is stored in a.

Multiplication Self-assignment Operator

The multiplication self-assignment operator (*=) multiplies a variable by a value and stores the result in the variable.

`a *= 5;`

In this example, a is multiplied by 5 and the result is stored in a.

Division Self-assignment Operator

The division self-assignment operator (/=) divides a variable by a value and stores the result in the variable.

`a /= 6;`

In this example, a is divided by 6 and the result is stored in a.

Modulus Self-assignment Operator

The modulus self-assignment operator (%=) divides a variable by a value and stores the modulus in the variable.

`a %= 5;`

In this example, a is divided by 5 and the remainder is stored in a.