Skip to main content

Batch Script Bitwise Operators

Bitwise Operators

Bitwise operators are available in Batch Script.

note

Bitwise is a level of operation that involves working with individual bits.

A bitwise operation operates on two-bit patterns of equal lengths by positionally matching their individual bits.

The following table lists the available bitwise operators.

OperatorDescription
&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 Operators
@echo off
set /A "Result = 48 & 23"
echo %Result%
set /A "Result = 16 | 16"
echo %Result%
set /A "Result = 31 ^ 15"
echo %Result%
16
16
16

Table of Contents