想实现对当前系统内存大小做平发根处理
@echo on
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=4 delims= " %%i in ('systeminfo^|find "Total Physical Memory"') do (
set str=%%i
)
set str=%str:,=%
set a=%str%,a*=1125,b=a
for /l %%a in (1,1,100) do set /a b=(b+a/b)/2
echo %b:~,-2%
pause
报Divide by zero error,是公式哪里不对吗??作者: forfiles 时间: 2012-9-10 20:23
想实现对当前系统内存大小做平发根处理
@echo on
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=4 delims= " %%i in ('systeminfo^|find "Total Physical Memory"') do (
set str=%%i
)
set str=%str:,=%
set a=%str%,a*=1125,b=a
for /l %%a in (1,1,100) do set /a b=(b+a/b)/2
echo %b:~,-2%
pause