@echo off ::script written by Michal Hanebach, Jan 2013 :loop echo. echo give two big integers to be added : set/p first=give first number : set/p second=give second number : call:LargeInt_add first second first if "%errorlevel%"=="1" (echo Too few parameters.) else (echo [%first%]) goto loop :LargeInt_add setlocal set left=%% %1 %% set left=%left: =% call set left=%left% set right=%% %2 %% set right=%right: =% call set right=%right% if defined left (if defined right (goto lrgintadd)) set exitcode=1 goto lrgintadd_endproc :lrgintadd set buff= set lastchar_l= set lastchar_r= if defined left (set lastchar_l=%left:~-1%) if defined right (set lastchar_r=%right:~-1%) if defined carry (set/a buff+=%carry%&set carry=) if defined lastchar_l (set/a buff+=%lastchar_l%) if defined lastchar_r (set/a buff+=%lastchar_r%) if %buff% GTR 9 ( set outvar=%buff:~-1%%outvar% set carry=%buff:~0,1% ) else ( set outvar=%buff%%outvar% ) if defined left (set left=%left:~0,-1%) if defined right (set right=%right:~0,-1%) if not defined left (if not defined right (set outvar=%carry%%outvar%&goto lrgintadd_opsucc)) goto lrgintadd :lrgintadd_opsucc set exitcode=0 :lrgintadd_endproc endlocal&set %3=%outvar%&exit/b%exitcode%
Jan 7, 2013
Function: LargeInt_add
My attempt to work around the 2^31-1 limit in the Command Processor. Works for me. Beta, because I can not say it will work in all cases, give it a try.
Labels:
batch_tip
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment