Everyone knows that in batch processing, it is impossible to perform operations on overly large numbers. So how can we break through this limitation? We hope everyone will post and discuss the solutions...
I here provide one of my ideas, which I call the "column vertical form method" because it is very similar to the "column vertical form" in primary school. That is, respectively multiply each digit in the following number by the data above, and then add up all the data to get the answer. This method is based on this...
Test code:
Explanation: The above code currently supports the multiplication of numbers within 100 digits; for the above code, there are at least other improvement solutions that can improve the running efficiency, that is, I mentioned in another post "Using Batch Processing to Do Interesting Math Problems" before, the segmented calculation method. It is recommended to divide into segments of 5 digits. In this way, a large number of repeated and frequent calculations can be avoided, thereby improving the running efficiency. As for the latter calculation method, it is still in the testing stage.
The above is just one of my solution ideas. I hope everyone will criticize and correct it!
I here provide one of my ideas, which I call the "column vertical form method" because it is very similar to the "column vertical form" in primary school. That is, respectively multiply each digit in the following number by the data above, and then add up all the data to get the answer. This method is based on this...
Test code:
@echo off
setlocal enabledelayedexpansion
echo Calculating...
echo.
set str1=123456789101112131415161718192021222324252627282930
set str2=123456789101112131415161718192021222324252627282930
echo %str1%
echo ×
echo %str2%
call :test %str1% "" ex
call :test %str2% _ ex_
for /l %%a in (0 1 %ex%) do (
for /l %%b in (0 1 %ex_%) do (
set /a mult=!num%%a!*!num%%b_!
set /a sum=%%a+%%b+1
rem Add up all data with the same number of digits: for example, add the digits in the tens place and the digits in the tens place;
set /a result!sum!+=!mult!
))
for /l %%a in (10000 -1 1) do (
if defined result%%a (
rem Define the variable for the previous digit
set /a last=%%a-1
set var=!result%%a!
rem If the number is greater than 10, carry over;
if !result%%a! GEQ 10 set /a result!last!+=!var:~0,-1!
set result=!var:~-1!!result!
)
)
echo.
echo =%result%
pause>nul
:test
for /l %%i in (0 1 100) do (
set var=%1
if "!var:~%%i,1!"=="" set /a %3=%%i-1 & goto :eof
rem Obtain the digits of thousands, millions, etc. respectively;
set /a num%%i%2=!var:~%%i,1!)
Explanation: The above code currently supports the multiplication of numbers within 100 digits; for the above code, there are at least other improvement solutions that can improve the running efficiency, that is, I mentioned in another post "Using Batch Processing to Do Interesting Math Problems" before, the segmented calculation method. It is recommended to divide into segments of 5 digits. In this way, a large number of repeated and frequent calculations can be avoided, thereby improving the running efficiency. As for the latter calculation method, it is still in the testing stage.
The above is just one of my solution ideas. I hope everyone will criticize and correct it!
Recent Ratings for This Post
( 1 in total)
Click for details
| Rater | Score | Time |
|---|---|---|
| redtek | +2 | 2006-11-19 03:36 |

