批量数学(获胜) [英] Math on batch (win)
问题描述
我正在开发一个 CMD 批处理.我想在其中做一些数学运算.这个公式:(x+1)100:y
I am developing a CMD batch. I want to do some math in it. This formula: (x+1)100:y
所以在批处理中,x = %x%,并且 y = %y%
.我知道如何设置变量.现在,如何批量计算呢?(WINDOWS CMD)
So in batch, x = %x%, and y = %y%
. I know how to set the variables. Now, how can batch calculate this? (WINDOWS CMD)
我需要额外的东西吗?
(我需要 Windows XP 到 7 的用户可以使用它.)
(I need this to be available to users of Windows XP to 7.)
推荐答案
set 命令支持一些有限的计算.在你的情况下,你想要:设置/a 结果=(100*x)/y
The set command supports some limited calculation. In your case, you want:
set /a result=(100*x)/y
运行 set/?
以查看有关受支持内容的完整文档./a
开关会自动进行变量替换,因此您可以使用 x
代替 %x%
.
Run set /?
to see full documentation on what is supported. The /a
switch does automatic variable substitution, so you can use x
instead of %x%
.
这篇关于批量数学(获胜)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!