Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi All,
I wrote a batch script as below:
I trying to add a number bigger than 2 million
ie 9011000513 to a increment number ie
1,2,3,4,5.=================================
@echo offsetlocal ENABLEDELAYEDEXPANSION
set COUNT=9011000513
for %%v in (1 2 3 4) do (
SET /A COUNT=!COUNT!+%%v
echo !COUNT!
)
PAUSE
=================================
But It hits an error as below.
=================================
Invalid number. Numbers are limited to 32-bits
of precision.
9011000513
Invalid number. Numbers are limited to 32-bits
of precision.
9011000513
Invalid number. Numbers are limited to 32-bits
of precision.
9011000513
Invalid number. Numbers are limited to 32-bits
of precision.
9011000513
Press any key to continue . . .
=================================How can I get the result of
9011000514
9011000515
9011000516
9011000517
9011000518?Thanks
-fsloke

@echo off setlocal enabledelayedexpansion set COUNT=9011000513 for %%v in (1 2 3 4) do ( call :add COUNT %%v echo !COUNT! ) pause goto :eof :add ::call with two arguments, the variable name ::and the number to be added to the contents of the ::variable. the variable name will be set to the result setlocal enabledelayedexpansion set add1=!%1! set add2=%2 set atotal= set astore= set acarry= :aloop if not defined add1 ( if defined acarry ( set add1=%acarry% set acarry= ) else ( set atotal=%add2%%atotal% goto aoutput ) ) if not defined add2 ( if defined acarry ( set add2=%acarry% set acarry= ) else ( set atotal=%add1%%atotal% goto aoutput ) ) if not defined acarry ( set /a astore=%add1:~-1%+%add2:~-1% ) else ( set /a astore=%add1:~-1%+%add2:~-1%+%acarry% set acarry= ) if !astore! lss 10 ( set atotal=%astore%%atotal% ) else ( set atotal=%astore:~-1%%atotal% set acarry=%astore:~0,-1% ) set astore= set add1=%add1:~0,-1% set add2=%add2:~0,-1% goto aloop :aoutput endlocal&set %1=%atotal% goto :eof

![]() |
Ideas for Software?
|
Vb6.0 data reports
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |