『楼 主』:
[讨论]长时间进行相同计算出错
我早上写了这个批处理,后来发现执行时间过长后会出错,出错代码为
SET /A S=(((%TIME:~7,1%-S9)*2+1)%%2*(%TIME:~7,1%-S9)*10)/(((%TIME:~7,1%-S9)*2+1)%%2*(%TIME:~7,1%-S9)*10-1) 出错时的两个变量分别为
%time:~7,1%=9
%s9%=9
出错时的结果为-1,正常结果为0
出错时间最长为48分钟,最短只有8分钟就有
完整代码:
@ECHO OFF
SET TIMEON=%TIME:~0,-3%
:TIME1
SET /A S9=%TIME:~7,1%,S1+=S
SET /A H=S1/3600,M=S1%%3600/60,S=S1%%3600%%60
ECHO stopwatch %H%:%M%:%S% current:%TIME:~0,-3% timeon:%TIMEON% secs=%S1% %S9%
SET /A S1/(S1-100000) 2>nul||GOTO NEXT
:TIME0
SET /A S=(((%TIME:~7,1%-S9)*2+1)%%2*(%TIME:~7,1%-S9)*10)/(((%TIME:~7,1%-S9)*2+1)%%2*(%TIME:~7,1%-S9)*10-1)
GOTO TIME%S%
|