How to perform modular operations in a package?

I am trying to write a batch file that performs operations depending on the result of a module operation performed on a given variable. However, I cannot figure out how to do it right.

First of all, to check my syntax for a mathematical operation, I tried to get a simpler script to get the desired results.

:START
SETLOCAL
SET /P Input-Num="Input Number: "
SET /A Input-Num=%Input-Num% %% 2
ECHO %Input-Num%
ENDLOCAL
PAUSE 
:END

If I introduce 5, the expected result will be 1. However, instead, I get a message with a message Missing operator., and then it displays 5.

What am I doing wrong here?

+5
source share
1 answer

SET /P - , 5 . , ,

+4

All Articles