CMD批处理文件丢失员错误 [英] CMD Batch File Missing Operator Error
本文介绍了CMD批处理文件丢失员错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
获得第3行一个缺少操作员错误执行在DOS批处理文件中的以下时 - 所以第二个变量结束了零 - 为什么会这样
SET VAR1 = 0.3
ECHO%VAR1%
SET / A VAR2 = 2 *%VAR1%
ECHO%VAR2%
解决方案
这是因为设置/ A
只能与整数工作。这点,那废墟你的语法。
作为一种解决方法,你可以使用(与大的数字):
SET VAR1 = 3/10
ECHO%VAR1%
SET / A VAR2 = 200 *%VAR1%
ECHO%VAR2%
这确实设置/一VAR2 = 200 * 3/10
注:为设置/ A
计算与只能为整数, 2 * 0.3
= 2 * 3/10
= 0.6
为您提供 0
只(不四舍五入,只是切割)
Getting a 'missing operator' error on line 3 when executing the following in a DOS batch file - so the second variable ends up as zero - why is this so?
SET VAR1=0.3
ECHO %VAR1%
SET /A VAR2=2*%VAR1%
ECHO %VAR2%
解决方案
that's because set /a
can work with integers only. It's the dot, that ruins your Syntax.
As a Workaround, you can use (with "big" numbers):
SET VAR1=3/10
ECHO %VAR1%
SET /A VAR2=200*%VAR1%
ECHO %VAR2%
That does set /a VAR2=200*3/10
Note: as set /a
calculates with integers only, 2*0.3
= 2*3/10
= 0.6
gives you 0
only (no rounding, just cutting)
这篇关于CMD批处理文件丢失员错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文