我一直在尝试制作一个可以暂时处理负数的批处理文件。我最好的猜测是在批处理文件中创建小“工程师”,在比较期间为每个数字添加1000,并在比较后将数字恢复为正常。 我的计算机运行Windows 8,当我运行这个批处理文件时,即使在“工程师”完成其工作之后,它也会说Beta(应该等于-93)大于所有数字。我不知道如何解决这个问题。帮助
@echo off
:PRELOAD
set alpha=0
set beta=0
set gamma=92
:MONKEYWRENCH
set /a beta=%beta% - 93
echo Monkey Wrench
:ENGINEERSTART
set /a alpha=%alpha% + 1000
set /a beta=%beta% + 1000
set /a gamma=%gamma% + 1000
:ECHOMONKEY1
echo Alpha = %alpha%
echo Beta = %beta%
echo Gamma = %gamma%
:COMPARE
echo Start Comparison
echo Alpha
if '%alpha%' GEQ '%beta%' echo Alpha is greater than Beta
if '%alpha%' LSS '%beta%' echo Alpha is lesser than Beta
if '%alpha%' GEQ '%gamma%' echo Alpha is greater than Gamma
if '%alpha%' LSS '%gamma%' echo Alpha is lesser than Gamma
echo Beta
if '%beta%' GEQ '%alpha%' echo Beta is greater than Alpha
if '%beta%' LSS '%alpha%' echo Beta is lesser than Alpha
if '%beta%' GEQ '%gamma%' echo Beta is greater than Gamma
if '%beta%' LSS '%gamma%' echo Beta is lesser than Gamma
echo Gamma
if '%gamma%' GEQ '%alpha%' echo Gamma is greater than Alpha
if '%gamma%' LSS '%alpha%' echo Gamma is lesser than Alpha
if '%gamma%' GEQ '%beta%' echo Gamma is greater than Beta
if '%gamma%' LSS '%beta%' echo Gamma is lesser than Beta
echo End Comparison
:ENGINEEREND
set /a alpha=%alpha% - 1000
set /a beta=%beta% - 1000
set /a gamma=%gamma% - 1000
:ECHOMONKEY2
echo Alpha = %alpha%
echo Beta = %beta%
echo Gamma = %gamma%
pause
答案 0 :(得分:2)
删除所有引号。
'%var%'
其中var = -83是字符串'-83'
- 包括引号。然后批处理逐个字符地执行 ALPHABETICAL 比较,因此'123'
小于'9'
,因为1
小于9