批处理文件FLOAT数学 [英] Batch File FLOAT math
本文介绍了批处理文件FLOAT数学的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个批处理,该批处理将使用输入变量来计算某个方程式. 等式是
Im trying to create a batch that will calculate a certain equation with Input variables. equation is
(%b%+(%b%*(88/100))+(%b%*(165/100))+(%b%*(%r%/100)))*%c%
我目前正在使用我在这里找到的代码,但似乎无法正常工作
im currently using code i found here but it doesn't seem to work properly
SETLOCAL EnableExtensions EnableDelayedExpansion
@echo off
echo Enter BaseCC
set /P b=
echo Enter Riven ( if none enter 1 )
set /P r=
echo Enter Combo Multiplier
set /P c=
call :calc_ 2 (%b%+(%b%*(88/100))+(%b%*(165/100))+(%b%*(%r%/100)))*%c%
echo !calc_v!
pause
goto :EOF
:calc_
set scale_=1
set calc_v=
for /l %%i in (1,1,%1) do set /a scale_*=10
set /a "calc_v=!scale_!*%2"
set /a calc_v1=!calc_v!/!scale_!
set /a calc_v2=!calc_v!-!calc_v1!*!scale_!
set calc_v=!calc_v1!.!calc_v2!
goto :EOF
如果b为20; r为114; c是3 结果应该是280.2
if b is 20; r is 114; c is 3 result should be 280.2
我得到的结果是180.0
The result i get is 180.0
推荐答案
感谢Stephan的建议,找到了解决方案. 它现在可以正常工作. 不知道我可以实现vbs.
Found the solution thanks to the suggestions of Stephan. it works correctly now. Didn't know i can implement vbs.
@echo off
set /p b=BaseCC=
set /p r=Riven=
set /p c=Combo=
echo WSH.Echo Eval(Wscript.Arguments(0))>>Q.vbs
cscript //nologo Q.vbs ((%b%+(%b%*(88/100))+(%b%*(165/100))+(%b%*(%r%/100)))*%c%)
Del "Q.vbs"
Pause>nul
这篇关于批处理文件FLOAT数学的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文