-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Mastering Windows PowerShell Scripting (Second Edition)
By :

Binary operators are used to perform bit-level operations. Each operator returns the numeric result of the operation:
-band
-bor
-bxor
-bnot
The result of -band
is a number where each of the bits is set in both the value on the left and the value on the right.
In the following example, the result is 2
:
11 -band 6
This operation can be shown in a table:
Bit value | 8 | 4 | 2 | 1 | |
Left-hand side | 11 | 1 | 0 | 1 | 1 |
Right-hand side | 6 | 0 | 1 | 1 | 0 |
| 2 | 0 | 0 | 1 | 0 |
The result of -bor
is a number where the bits are set in either the value on the left or right.
In the following example, the result is 15
:
11 -bor 12
This operation can be shown in a table:
Bit value | 8 | 4 | 2 | 1 | |
Left-hand side | 11 | 1 | 0 | 1 | 1 |
Right-hand side | 12 | 1 | 1 | 0 | 0 |
| 15 | 1 | 1 | 1 | 1 |
The result of -bxor
is a number where the bits are set in either the value on the left, or the value on the right, but not both.
In the following example, the result is 11
:
6 -bxor 13
This operation can be shown in a table:
Bit value... |
Change the font size
Change margin width
Change background colour