Categories
Scripts Windows Batch

Bitwise Operator

Batch script supports logical operators for bitwise operations only. Unlike other rich programming languages, batch program does not support conditional logical operators.

06Operators_Bitwise.bat

::this program will demonstrate bitwise operators, following operators are supported
::& Bitwise AND
::| Bitwise OR
::^ Bitwise Exclusive OR 

@echo off

set /A var_1=3
set /A var_2=5

set /A bitwiseAND="%var_1%&%var_2%"
set /A bitwiseOR="%var_1%|%var_2%"
set /A bitwiseEXOR="%var_1%^%var_2%"


echo "bitwiseAND :: %bitwiseAND%"
echo "bitwiseOR :: %bitwiseOR%"
echo "bitwiseEXOR :: %bitwiseEXOR%"

Output

Leave a comment

Design a site like this with WordPress.com
Get started