Skip to content

Batch Script Bitwise Operators

Learn how to use bitwise AND (&), OR (|), and XOR (^) operators in Windows Batch Scripting for binary-level data manipulation.

Bitwise operators are available in Batch Script.

The following table lists the available bitwise operators.

Operator Description
& This is the bitwise and operator
| This is the bitwise or operator
^ This is the bitwise xor or exclusive or operator

Example

The following code snippet shows how the various operators can be used.

Example of Bitwise Operatorsbatch
@echo off
set /A "Result = 48 & 23"
echo %Result%
set /A "Result = 16 | 16"
echo %Result%
set /A "Result = 31 ^ 15"
echo %Result%
Outputplaintext
16
16
16
Navigation