Relational operators allow of the comparison of objects.
The following table lists the available relational operators.
| Operator | Description | Example |
|---|---|---|
EQU |
Tests the equality between two objects | 2 EQU 2 will give true |
NEQ |
Tests the difference between two objects | 3 NEQ 2 will give true |
LSS |
Checks to see if the left object is less than the right operand | 2 LSS 3 will give true |
LEQ |
Checks to see if the left object is less than or equal to the right operand | 2 LEQ 3 will give true |
GTR |
Checks to see if the left object is greater than the right operand | 3 GTR 2 will give true |
GEQ |
Checks to see if the left object is greater than or equal to the right operand | 3 GEQ 2 will give true |
Example
The following code snippet shows how the various operators can be used.
@echo off
set /A a=5
set /A b=10
if %a% EQU %b% echo A is equal to than B
if %a% NEQ %b% echo A is not equal to than B
if %a% LSS %b% echo A is less than B
if %a% LEQ %b% echo A is less than or equal B
if %a% GTR %b% echo A is greater than B
if %a% GEQ %b% echo A is greater than or equal to BA is not equal to than B
A is less than B
A is less than or equal B