Arithmetic operators
Arithmetic operators are used to perform numeric calculations. The arithmetic operators in PowerShell are as follows:
- Addition:
+
- Subtraction:
-
- Multiplication:
*
- Division:
/
- Remainder:
%
As well as its use in numeric calculations, the addition operator may also be used with strings, arrays, and hashtables. The multiplication operator may also be used with strings and arrays.
The addition operator attempts to add two values together.
Addition operator
The addition operator may be used to add values together, or any object type that supports addition.
For example, the following simple addition operation will result in the value 5.14159
:
2.71828 + 3.14159
The addition operator may also be used to concatenate strings:
'good' + 'bye'
This style of concatenation can be applied to the example used with a sub-expression:
$word = 'one'
"Length: " + $word.Length
If an attempt is made to concatenate a...