Reputation: 125
Why do I get with the code below the error message:
Missing operator.
@echo off
set plvl=1
set pexp=0
set pexpend=100
set aiexp=10
set pexplvl2=3.1
if "%plvl%"=="1" set /a pexp=%pexp% + %pexpend% / %aiexp% * %pexplvl2%
Upvotes: 0
Views: 104
Reputation: 80073
Batch mathematics is always in integers. Batch sees the .
in 3.1
and complains because it is expecting an operator (+-/%*)
Try replacing 3.1
with 31/10
- but remember, the result will be truncated. There will be no decimals.
For example 29/10
produces 2
as result of the integer division and not 3
as a floating point division with result 2.9
and a subsequent rounding to nearest integer value would produce.
Upvotes: 2