批处理数学(Win) [英] 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%, and 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)
我需要一些额外的东西吗?
Do I need something extra?
(我需要Windows XP到7的用户可以使用它.)
(I need this to be available to users of Windows XP to 7.)
推荐答案
set命令支持一些有限的计算.您的情况是:
set /a result=(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%
.
这篇关于批处理数学(Win)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!