```code
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: ::
:: nd.bat ::
:: ::
:: by Shilyx mailto oversleep@163.com (C)2006.9.4 ::
:: ::
:: Batch program to convert a fraction to a decimal, supports infinite decimals, and the repeating part is enclosed in brackets ::
:: ::
:: Usage: Enter at the command line in the following format: nd a b ::
:: where parameter a represents the numerator and parameter b represents the denominator ::
:: You can also run it directly without parameters, and the program will prompt for input ::
:: ::
:: Note: The program runs in the script environment. It is slow for large denominators, generally do not exceed 3000 ::
:: ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal EnableDelayedExpansion
if "%2"=="" goto input
set /A N=%1
set /A D=%2
goto compute
:input
echo Input N:
set /p NN=
set /A N=%NN%
echo Input D:
set /p DD=
set /A D=%DD%
goto compute
:compute
if %N%==0 echo Wrong Input && goto input
if %D%==0 echo Wrong Input && goto input
set str=
for /L %%a in (1,1,%D%) do @set /A Left%%a=0
for /L %%a in (1,1,%D%) do @set /A Result%%a=0
set /A int_part="%N%/%D%"
set /A N="%N%%%%D%"
set /A tool=%N%
if %tool%==0 echo The result of expression "%N%/%D%" is %int_part% && goto :EOF
set /A turn=1
:start
set /A "tool*=10"
set /A Result%turn%="%tool%/%D%"
set /A Left="%tool%%%%%D%"
if %Left%==0 set /A begin=-1 && set /A end="%turn%" && goto endCompute
if %Left%==%N% set /A begin=0 && set /A end="%turn%" && goto endCompute
if not "!Left%Left%!"=="" set /A begin="!Left%Left%!" && set /A end="%turn%" && goto endCompute
set /A Left%Left%=%turn%
set /A tool=%Left%
set /A "turn+=1"
goto start
:endCompute
if "%3"=="" echo The result of expression "%N%/%D%" is
set result=#
for /L %%i in (1,1,%end%) do @set result=!result!!Result%%i!
set result=%result:~1%
if %begin%==-1 echo %int_part%.%result% && goto end
if %begin%==0 echo %int_part%. && goto end
echo %int_part%.!result:~0,%begin%!
:end
if "%2"=="" echo. && echo Press any key to quit application && pause>nul
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: The return value of begin has certain meanings: ::
:: -1: Indicates that the division has been successfully completed, and it can be output directly ::
:: 0: Indicates that the new remainder is one, returning directly to the start ::
:: Other: Indicates that it is the most common number, with a neck before the repeating part ::
:: int_part represents the integer part of the result ::
:: tool is an iterative variable, and it is the one working all the time ::
:: turn is the index value, indicating the current position of the array ::
:: Two arrays are used in the program for statistical purposes ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: ::
:: nd.bat ::
:: ::
:: by Shilyx mailto oversleep@163.com (C)2006.9.4 ::
:: ::
:: Batch program to convert a fraction to a decimal, supports infinite decimals, and the repeating part is enclosed in brackets ::
:: ::
:: Usage: Enter at the command line in the following format: nd a b ::
:: where parameter a represents the numerator and parameter b represents the denominator ::
:: You can also run it directly without parameters, and the program will prompt for input ::
:: ::
:: Note: The program runs in the script environment. It is slow for large denominators, generally do not exceed 3000 ::
:: ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal EnableDelayedExpansion
if "%2"=="" goto input
set /A N=%1
set /A D=%2
goto compute
:input
echo Input N:
set /p NN=
set /A N=%NN%
echo Input D:
set /p DD=
set /A D=%DD%
goto compute
:compute
if %N%==0 echo Wrong Input && goto input
if %D%==0 echo Wrong Input && goto input
set str=
for /L %%a in (1,1,%D%) do @set /A Left%%a=0
for /L %%a in (1,1,%D%) do @set /A Result%%a=0
set /A int_part="%N%/%D%"
set /A N="%N%%%%D%"
set /A tool=%N%
if %tool%==0 echo The result of expression "%N%/%D%" is %int_part% && goto :EOF
set /A turn=1
:start
set /A "tool*=10"
set /A Result%turn%="%tool%/%D%"
set /A Left="%tool%%%%%D%"
if %Left%==0 set /A begin=-1 && set /A end="%turn%" && goto endCompute
if %Left%==%N% set /A begin=0 && set /A end="%turn%" && goto endCompute
if not "!Left%Left%!"=="" set /A begin="!Left%Left%!" && set /A end="%turn%" && goto endCompute
set /A Left%Left%=%turn%
set /A tool=%Left%
set /A "turn+=1"
goto start
:endCompute
if "%3"=="" echo The result of expression "%N%/%D%" is
set result=#
for /L %%i in (1,1,%end%) do @set result=!result!!Result%%i!
set result=%result:~1%
if %begin%==-1 echo %int_part%.%result% && goto end
if %begin%==0 echo %int_part%. && goto end
echo %int_part%.!result:~0,%begin%!
:end
if "%2"=="" echo. && echo Press any key to quit application && pause>nul
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: The return value of begin has certain meanings: ::
:: -1: Indicates that the division has been successfully completed, and it can be output directly ::
:: 0: Indicates that the new remainder is one, returning directly to the start ::
:: Other: Indicates that it is the most common number, with a neck before the repeating part ::
:: int_part represents the integer part of the result ::
:: tool is an iterative variable, and it is the one working all the time ::
:: turn is the index value, indicating the current position of the array ::
:: Two arrays are used in the program for statistical purposes ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



