China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-20 11:31
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Joint Participation] [Challenge Ideas] [Batch Processing Floating-Point Operations] DigestI View 41,135 Replies 136
Floor 91 Posted 2006-10-18 05:57 ·  中国 甘肃 平凉 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Welcome to keep testing~



@echo off
title 批处理除法运算脚本 by:Ye - * bbs.cn-dos.net
:start
cls
call :del.bat
echo.
echo bbs.cn-dos.net
echo --------------------------------------------------------------------------------
echo 程序用途: 两个数的除法运算,被除数和除数都可以是小数
echo 使用说明: 1.被除数或除数的整数位和小数位之和最多9位,超过可能会出错
echo 不过通过下面这个例子,原理上被除数可以计算到任意位:
echo 789/9=(7/9)的值补00+(8/9)的值补0+9/9
echo 2.被除数或除数可简写输入,输入下面这些都可以执行: 9. or .9
echo 3.任何位置输入 ^&、^"、^<、^>、^|、空格 中的任何一个都会引起错误
echo 4.如果出现"无效数字。数字精确度限为 32 位",是位数太多了,结果无效
echo --------------------------------------------------------------------------------
set num1_k=
set /p num1_k= 输入被除数:
if == goto start
:: 判断是否为纯数字
call :pan_c_num %num1_k%
:: 判断是否输入两个以上的.
call :q_wei %num1_k%

set num2_k=
set /p num2_k= 输入除数:
if == goto start
call :pan_c_num %num2_k%
call :q_wei %num2_k%

set num1=%num1_k%
set num2=%num2_k%

:: 判断常见的几种情况
if %num2%==0 (echo 错误:除数不可以为0&pause>nul&goto start)
if %num1%==0 (set zhi=0& goto show)
if %num1%==%num2% (set zhi=1& goto show)
if %num1%==. (set zhi=0& goto show)
if %num2%==. (echo 错误:除数不可以为.&pause>nul&goto start)

:: 为.xx xx.和xx补全
>var_.txt echo %num1%
find "." var_.txt>nul&& (if %num1:~0,1%==. set num1=0%num1%
if %num1:~-1,1%==. set num1=%num1%0)||set num1=%num1%.0
>var_.txt echo %num2%
find "." var_.txt>nul&& (if %num2:~0,1%==. set num2=0%num2%
if %num2:~-1,1%==. set num2=%num2%0)||set num2=%num2%.0

:: 算全部的位数
call :q_wei %num1%
set n1_wei=
set /p n1_wei=<var_.txt
call :q_wei %num2%
set n2_wei=
set /p n2_wei=<var_.txt

:: 算小数点以后的位数
call :x_wei %num1% %n1_wei%
set x1_wei=
set /p x1_wei=<var_.txt
set /a x1_wei=x1_wei-1
call :x_wei %num2% %n2_wei%
set x2_wei=
set /p x2_wei=<var_.txt
set /a x2_wei=x2_wei-1

:: 比较小数位大小,并补小数位到位数相同
if %x1_wei%==%x2_wei% goto wei_t
set max_wei=%x1_wei%
if %max_wei% lss %x2_wei% (set max_wei=%x2_wei%)
set /a bu1_wei=%max_wei%-%x1_wei%
set /a bu2_wei=%max_wei%-%x2_wei%
if %bu1_wei%==0 goto bu_w1_ok
call :bu_xwei %bu1_wei%
set x1_wei_0=
set /p x1_wei_0=<var_.txt
set num1=%num1%%x1_wei_0%
:bu_w1_ok
if %bu2_wei%==0 goto bu_w2_ok
call :bu_xwei %bu2_wei%
set x2_wei_0=
set /p x2_wei_0=<var_.txt
set num2=%num2%%x2_wei_0%
:bu_w2_ok
:wei_t
set x_wei=0

:: 去除.
set num1=%num1:.=%
set num2=%num2:.=%

:: 算新的全部的位数
call :q_wei %num1%
set n1_xwei=
set /p n1_xwei=<var_.txt
call :q_wei %num2%
set n2_xwei=
set /p n2_xwei=<var_.txt

:: 位数大于8无法计算,这里,因为set /a 好象最大可以计算到8888888/9999999
if 8 LEQ %n1_xwei% (echo 数字位数太多,暂时计算不了&pause>nul&goto start)
if 8 LEQ %n2_xwei% (echo 数字位数太多,暂时计算不了&pause>nul&goto start)

:: 第一位如果是0就去除
if %num1:~0,1%==0 (
call :qu_0 %num1% %n1_xwei%
set num1=
set /p num1=<var_.txt
)

if %num2:~0,1%==0 (
call :qu_0 %num2% %n2_xwei%
set num2=
set /p num2=<var_.txt
)

:: 这是防止输入0.0 0.00 等 00 000 等=0的数字而无法执行程序
:: 因为当某个数为0时,第一位如果是0就去除,这样这个数就是空了,写入文件的时候为"ECHO 处于关闭状态。"
>var_.txt echo %num1%
find "关闭状态" var_.txt>nul&&(set zhi=0& goto show)
>var_.txt echo %num2%
find "关闭状态" var_.txt>nul&&(echo 错误:除数不可以为0&pause>nul&goto start)

:: 比较大小,1>2才继续运行
:fc_
if %num1% GEQ %num2% goto fc_ok
set /a num1=%num1%*10
set /a x_wei=x_wei+1
goto fc_
:fc_ok

:: 开始计算
call :jisuan %num1% %num2%
set zhi=
set /p zhi=<var_.txt

:: 开始补小数位
if %x_wei%==0 goto show

:: 去除值中的.
set zhi_=
set zhi_=%zhi:.=%

if %x_wei%==1 (
set zhi_=
set zhi=0.%zhi_%
goto show
)

:: 其余就是%x_wei%大于1的情况
set /a x_wei-=1
call :bu_xwei %x_wei%
set zhi_bu=
set /p zhi_bu=<var_.txt
set zhi=
set zhi=0.%zhi_bu%%zhi_%

goto show
:: 显示结果
:show
call :del.bat
echo --------------------------------------------------------------------------------
echo 运算结果:
echo %num1_k%/%num2_k%=%zhi%
echo --------------------------------------------------------------------------------
echo 按任意键继续计算......&pause>nul&goto start

:: $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

:q_wei
set var=
set var=%1
setlocal ENABLEDELAYEDEXPANSION
set n=0
set d_geshu=0
:start_a
set "var_=!var:~%n%,1!"
if "%var_" == "" goto end_a
:: 记录点的个数
if == set /a d_geshu=d_geshu+1
set /a n=n+1
goto start_a
:end_a
>var_.txt echo %n%
:: 判断.的个数,有两个以上的.退出
if %d_geshu% gtr 1 (echo 错误:被除数或除数只可以由数字和一个.组成&pause>nul&goto start)
goto :eof

:del.bat
if exist var_.txt del /q var_.txt>nul
goto :eof

:x_wei
setlocal ENABLEDELAYEDEXPANSION
set var=
set var=%1
set n=0
:start_b
set "var_=!var:~-%n%,1!"
if "%var_"=="." goto end_b
set /a n=n+1
if %n%==%2 goto end_b
goto start_b
:end_b
>var_.txt echo %n%
goto :eof

:jisuan
set var1=
set var2=
set n=0
set zhi_x=
set var1=%1
set var2=%2
:start_c
if %var1%==0 goto end_c
set /a zhi=%var1%/%var2%
set /a var1=(var1-%var2%*%zhi%)*10
set /a n=n+1
if %n%==2 (set zhi_x=%zhi_x%.%zhi%) else (set zhi_x=%zhi_x%%zhi%)
:: 这里的if %n%==10是算10次,为了算的更精确,可以设置更大
if %n%==10 goto end_c
goto start_c
:end_c
>var_.txt echo %zhi_x%
goto :eof

:bu_xwei
set var=
set var=%1
set wei=
set n=0
:start_d
set /a n=n+1
set wei=%wei%0
if %n%==%var% goto end_d
goto start_d
:end_d
>var_.txt echo %wei%
goto :eof


:qu_0
set var=
set var=%1
setlocal ENABLEDELAYEDEXPANSION
set n=0
set shu=
:start_e
set "var_=!var:~%n%,1!"
if not "%var_"=="0" goto end_e
set /a n=n+1
goto start_e
:end_e
:start_e_1
set "var_=!var:~%n%,1!"
set shu=%shu%%var_%
set /a n=n+1
if %n%==%2 goto end_e_1
goto start_e_1
:end_e_1
>var_.txt echo %shu%
goto :eof

:pan_c_num
:: 判断是否为纯数字,先替换了.为空
set var_=%1
set var_=%var_:.=%
>var_.txt echo %var_%
findstr "^*$" var_.txt>nul||(echo 错误:被除数或除数只可以由数字和一个.组成&pause>nul&goto start)
goto :eof


Floor 92 Posted 2006-10-19 08:56 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
How many digits does your script support?
Input dividend:99.66666
Input divisor:9.966666
Too many digits, can't calculate it for now
Floor 93 Posted 2006-10-19 10:07 ·  中国 浙江 宁波 电信
初级用户
Credits 44
Posts 15
Joined 2006-10-18 12:14
19-year member
UID 66379
Status Offline
Idea:
The two numbers have limited length:
FOR /L %%i IN (start,step,end) DO if "%num1:~"%%i",1" == "".""set set num1=%%i
to get the decimal-point position.
If there are many or it's unknown, just use a loop.
set /a i=0
:start
if "%num1:~"%%i",1" == "".""set set num1小数点位置=%%i &goto :end &::find seems to be an external command in XP
set /a i+=1
goto :start
Get the decimal-point positions of the two numbers.
Starting from the decimal point, loop to calculate the integer part.
For example:
set /a k=num1小数点位置
set /a j=num2小数点位置
:start1
if %num1:%k%,1% =="" set num11=0
if %num2:%j%,1% =="" set num22=0
set /a num11=%num1:%k%,1%
set /a num22=%num2:%j%,1%
set /a Valu=num11+num22
set /a k+=1 &set /a j+=1
if if %num1:%k%,1% =="" if %num2:%j%,1% =="" else :goto :end1
Handle the digits after the decimal point the same way.
Then use ECHO to output
I haven't tested whether the intermediate variable in %num2:%j%,1% can use ALT+8 for calculation.
Floor 94 Posted 2006-10-19 21:27 ·  中国 甘肃 兰州 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Originally posted by qwe1234567 at 2006-10-19 08:56:
How many digits does your script support?
Input dividend:99.66666
Input divisor:9.966666
Too many digits, can't calculate it for now

I set it to less than 7 in there; you can remove that and take a look
Floor 95 Posted 2006-10-20 01:27 ·  中国 浙江 宁波 电信
初级用户
Credits 44
Posts 15
Joined 2006-10-18 12:14
19-year member
UID 66379
Status Offline
rem The test environment is WINXPSP2
::C:\>ver
::
::Microsoft Windows XP
@echo off
set asicc=智123445679890弱ceho
%asicc:~-3,1%%asicc:~-4,1%%asicc:~-2% %asicc:~-5,1%%asicc:~0,1%制作:QQ%asicc:~4,2%%asicc:~1,1%%asicc:~6,1%%asicc:~5,1%%asicc:~-6,1%%asicc:~2,1%%asicc:~3,1%%asicc:~12,1%
set /p num1=请输入数字1:
set /p num2=请输入数字2:
::set num1=%num1%00&set num2=%num2%00

REM Get the decimal-point positions of num1 and num2
set /a i=0
:start1
call set num11=%%num1:~%i%,1%%&call set num22=%%num2:~%i%,1%%
::echo %num11% ,,,,,%num22%,,,,%num111%,,,,%num222% &pause
if "%num11%" == "." set n1=%i%&set a1=true
if "%num22%" == "." set n2=%i%&set a2=true
if "%a1%" == "true" if "%a2%" == "%a1%" goto :next2
set /a i+=1
goto :start1

:next2
echo Finished decimal point 1 position %n1% ,,,,decimal point 2 position %n2%,,,num1=%num1%,,,num2=%num2%
Rem Get the sum result of the fractional digits of the two numbers
set/a a1=n1&set /a a2=n2&::a1,a2 are reused here
::echo a1=%a1% n1=%n1% a2=%a2% n2=%n2%
set /a value=0
:start2
set/a n1+=1&set /a n2+=1
call set t1=%%num1:~%n1%,1%%&call set t2=%%num2:~%n2%,1%%
::echo t1=%t1% t2=%t2%
if "%t1%" == "" call set value=%value%%%num2:~%n2%%%& goto :next3
if "%t2%" == "" call set value=%value%%%num1:~%n1%%%& goto :next3
set /a tmp1=%t1%+%t2% &set tmp2=%value:~-1%
if "%tmp1:~1,2%" NEQ "" set/a tmp2+=1
::echo tmp2=%tmp2%
set value=%value:~0,-1%%tmp2%%tmp1:~-1%
::echo %value% &pause
goto start2

:next3
set z=%value:~0,1%
echo value=%value%
echo z=%z%
pause
REM Calculate the integer part
::set value2=0
:start3
set/a a1-=1&set /a a2-=1
call set t1=%%num1:~%a1%,1%%&call set t2=%%num2:~%a2%,1%%
::echo t1=%t1% t2=%t2%
set /a tmp1=%t1%+%t2%+%z%
if "%tmp1:~1,2%" NEQ "" set/a z=1
set value2=%tmp1:~-1%%value2%
if "%a1%" == "0" call set value1=%%num2:~0,%a2%%%& goto :next4
if "%a2%" == "0" call set value1=%%num1:~0,%a1%%%& goto :next4
::echo value2=%value2% tmp2=%tmp2% zcarry=%z% tmp1 sum result=%tmp1%&pause
set /a z=0
goto start3

:next4
echo value1=%value1% z=%z% value2=%value2% &pause
REM Calculate the possible remaining part +1
if "%z%" NEQ "1" goto :end
set /a a1=a1-a2
if "%a1:~0,1%" == "-" set a1=%a1:~1%
echo on
:start4
if "%a1%" == "0" goto :end
set /a t1=%a1%
set /a a1-=1
call set tmp1=%%value1:~%a1%,1%%
::echo Get the digit at position %a1%: %tmp1%
set/a tmp1+=1
call set tmp2=%%value1:~0,%a1%%%
call set i=%%value1:~%t1%%%
echo Digits from 0 to position %a%: %tmp2%
set value1=%tmp2%%tmp1:~-1%%i%
echo value1 (result after +1)=%value1% tmp1 (digit being incremented)=%tmp1% tmp2 (chars 1-a1)=%tmp2% i chars from current to the end=%i% &pause
set z=0
if "%tmp1:~1,2%" NEQ "" set z=1&goto :start4
:end
if "%z%"=="0" set z=
echo The result number is=%z%%value1%%value2%.%value:~1%
%asicc:~-3,1%c%asicc:~-2% Thanks for using this software. If there are any problems please contact QQ:%asicc:~4,2%15%asicc:~4,1%0230
echo Press any key to exit&pause >nul 2>nul

::Pending test formulas::Dizzy, there are too many errors. But there may still be errors
::Length is the length SET can hold.
::The program digit count can be increased by looping. That is, instead of calculating one digit at a time, using two-digit with two-digit or larger would be a bit faster. Here the loop variable is 1
::Question for OP, can a program be constructed to run its own program?

[ Last edited by yfd11 on 2006-10-20 at 06:26 ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +6 2006-10-20 01:31
Floor 96 Posted 2006-10-20 01:38 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
The one on the 2nd floor is using a program
Making it purely bat is for training batch-file ability

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 97 Posted 2006-10-20 01:56 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
19-year member
UID 58987
From 湖南.娄底
Status Offline
I don't know exactly what function the script in the 95th-floor post is implementing; it seems like there are some problems with the variables.
Floor 98 Posted 2006-10-20 02:25 ·  中国 湖南 娄底 新化县 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
19-year member
UID 58987
From 湖南.娄底
Status Offline
After discussing this for so long I'm really getting a bit tired of it. Brother he200307's division algorithm isn't mature enough, and some details aren't handled carefully enough. I didn't look through your code carefully. Here I'll help you solve the final decimal carry problem. The code is a bit verbose.


@echo off
setlocal enabledelayedexpansion
set /p ii=请输入一个浮点数:
set /p pp=请选择小数点需要进的位数:
call :integer %ii%
set one=%num%
set /a ok=one-pp
set "ii=%ii:.=%"
if %pp% lss %one% (
set result=!ii:~0,%ok%!.!ii:~%ok%!
) else (
call :plus %ok:~1%
set result=0.!ii:~0,%ok:~1%!!ii:~%ok:~1%!
)
echo 进位结果=%result%
pause
goto :eof

:integer
set temp=%1
:integer_
if not "%temp:~0,1%"=="." (
set /a num+=1
set temp=%temp:~1%
goto integer_
)
goto :eof
:plus
for /l %%i in (1,1,%1) do (
set ii=0!ii!
)
goto :eof


[ Last edited by pengfei on 2006-10-21 at 01:14 ]
Floor 99 Posted 2006-10-20 02:33 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Originally posted by electronixtar at 2006-10-20 01:38:
The one on the 2nd floor is using a program
Making it purely bat is for training batch-file ability

Strongly agree with this point of view.

  The two threads posted by brother redtek are both for training our batch-file ability.
Floor 100 Posted 2006-10-20 03:01 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
When I run the code in the 95th-floor post under 2000, it just displays all kinds of messy stuff. I don't even know what the result is. Isn't that code supposed to be for calculation?
Floor 101 Posted 2006-10-20 03:40 ·  中国 甘肃 兰州 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
No matter how many digits the dividend has, it can be done: 789/9=(7/9) value padded with 00+(8/9) value padded with 0+9/9
I haven't thought of a good method for the divisor
Floor 102 Posted 2006-10-20 05:06 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
I'll also post a division script. It has passed my testing with no problems. Please test it, everyone:
@echo off
cls
title China DOS Union Forum made by qwe1234567
color 17
setlocal enabledelayedexpansion
if not %1*==* (set num1=%1&if not %2*==* (set num2=%2&goto jmp) ELSE goto err)
:input
set num1=
set num2=
echo Real Number Division Script
echo.
echo In theory, this script can perform division on real numbers where the dividend has N digits and the divisor is within 8 digits
echo.
echo Note: Other than Arabic numerals, the first character may be the "-" sign, and at most one "." is allowed,
echo no other characters are allowed. Otherwise, it will all be treated as invalid input...
echo.
echo China DOS Union Forum made by qwe1234567
set/p num1=Please enter the dividend:
set/p num2=Please enter the divisor:
:jmp
set fh1=
set fh2=
set fh=
if %num1%*==* goto err
if %num2%*==* goto err
if %num1:~0,1%==- set fh1=-&set num1=%num1:~1%
if %num2:~0,1%==- set fh2=-&set num2=%num2:~1%
if %fh1%*==-* (if %fh2%*==* set fh=-) else if %fh2%*==-* set fh=-
set err=0
echo %num1%|find ".">nul&&set num1=0%num1%0
call :qc %num1% num1
echo %num2%|find ".">nul&&set num2=0%num2%0
call :qc %num2% num2
if %err%==1 goto err
for /f "tokens=1* delims=." %%a in ("%num1%") do (set o1=%%a
set t1=%%b)
for /f "tokens=1* delims=." %%a in ("%num2%") do (set o2=%%a
set t2=%%b)
call :qs0 %o1%
set o1=%sw%
call :qs0 %o2%
set o2=%sw%
call :qw0 %t1%
set t1=%sw%
call :qw0 %t2%
set t2=%sw%
if not %t1%==0 (set o3=%o1%.%t1%) else set o3=%o1%
if not %t2%==0 (set o4=%o2%.%t2%) else set o4=%o2%
if %o4%==0 goto err
if %o3%==0 echo The result is 0÷%fh2%%o4%=0&goto input
call :js %t1%
set s1=%sw%
call :js %t2%
set s2=%sw%
If %s1% geq %s2% (set/a s3=s1-s2
call :j0 !s3! %t2%
set t2=!sw!
) ELSE (set/a s3=s2-s1
call :j0 !s3! %t1%
set t1=!sw!)
set tmp1=%o1%%t1%
set tmp2=%o2%%t2%
call :qs0 %tmp2%
set tmp2=%sw%
call :js %sw%
set s2=%sw%
call :qs0 %tmp1%
set tmp1=%sw%
call :js %sw%
set s1=%sw%
set/a zsw=s1-s2
call :qw0 %tmp2%
set tmp2=%sw%
call :js %sw%
set s2=%sw%
if %s2% GTR 8 echo Exceeded the calculation range!!&GOTO input
set tmp1=%tmp1%00000000000000000000000000000000000000000
set sw=!tmp1:~0,%s2%!
if %sw% geq %tmp2% set/a zsw+=1
set sw=%tmp1:~0,9%
set sw1=%tmp1:~9%
set jg=
:ksjs
set/a jg0=sw/tmp2
set/a sw=sw%%tmp2*10+%sw1:~0,1%
set sw1=%sw1:~1%
set jg=%jg%%jg0%
if not %sw1%.==. goto ksjs
if %zsw% lss 1 (for /l %%c in (0,-1,!zsw!) do set jg=0!jg!) else goto jxs
set o1=%jg:~0,1%
set o2=%jg:~1%
goto xs
:jxs
set o1=!jg:~0,%zsw%!
set o2=!jg:~%zsw%!
:xs
call :qw0 %o2%
set o2=%sw%
if %o2%==0 (set jg=%o1%) else set jg=%o1%.%o2%
echo The result is:
echo %fh1%%o3%÷%fh2%%o4%=%fh%%jg%
pause
cls
goto input

:qs0
set sw=%1
:qs1
if %sw%==0 goto :eof
if %sw:~0,1%==0 set sw=!sw:~1!&goto qs1
goto :eof
:qw0
set sw=%1
:qw1
if %sw%==0 goto :eof
if %sw:~-1%==0 set sw=!sw:~0,-1!&goto qw1
goto :eof
:js
set sw=0
set sw1=%1
if %sw1%==0 set sw=1&goto :eof
:js1
if not %sw1%*==* set sw1=%sw1:~1%&set/a sw+=1&goto js1
goto :eof
:qc
echo %1|find ".">nul||set %2=%1.0
for /f "tokens=1* delims=." %%i in ("%1") do echo %%i%%j|findstr "^*$">nul||set err=1
goto :eof
:j0
set sw=%2
if %1==0 goto :eof
for /l %%c in (1,1,%1) do set sw=!sw!0
goto :eof
:err
echo You entered illegal characters, or the divisor is 0!
echo Please re-enter...
goto input
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
+6 2006-10-20 20:11
Floor 103 Posted 2006-10-20 05:08 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 104 Posted 2006-10-20 05:21 ·  中国 甘肃 兰州 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
qwe1234567 moderator, add a bit of explanation~ or at least talk about the basic idea~
Floor 105 Posted 2006-10-20 05:35 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Then I'll briefly explain:
1: Check errors and signs
2: Align the decimal points
3: Count the number of digits in the integer part
4: Add 41 zeros to the tail of the dividend
5: Remove zeros from the tail of the divisor
6: Start calculating
7: Determine the position of the decimal point
8: Output the result
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
+6 2006-10-20 20:11
Forum Jump: