https://zhidao.baidu.com/question/180631496511289124.html?qbl=relate_question_1&word=bat%20%C1%BD%CE%BB%CA%FD%CF%E0%B3%FD%20%D0%A1%CA%FD%B5%E3%20set
应该说bat只能简单计算且计算式只能是整数,结果中小数部分直接被舍弃
但可以想办法先将需要的小数位扩大为整数,通过字符串的处理后得到需要的带小数的值,比如计算 11/3 保留两位小数 (4舍5入)
@echo off
set/a a=11,b=3,x=a/b
echo 直接计算会取整:%a%÷%b%=%x%
set/a a2=a*1000
set/a x=a2/b+5
set x=%x:~,-3%.%x:~-3,2%
echo 精确(4舍5入)到两位小数: %a%÷%b%=%x%
pause
=====保留一位小数
set x=%x:~,-2%.%x:~-2,1%
REM Select two decimal digits for all operations SET /A VAR=250+310 ECHO RESULT: %VAR:~0,-2%.%VAR:~-2%
rem Set "ONE" variable with two decimal places:
SET ONE=100
rem To multiply two FP numbers, divide the result by ONE:
SET /A MUL=A*B/ONE
rem To divide two FP numbers, multiply the first by ONE:
SET /A DIV=A*ONE/B
https://*.com/questions/25951196/set-command-floating-point-numbers?noredirect=1