中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-29 08:04
47,816 topics / 349,916 posts / today 0 new / 48,265 members
DOS批处理 & 脚本技术(批处理室) » Solutions to Extra-large Number Operations
Printable Version  2,315 / 13
Floor1 youxi01 Posted 2006-11-19 02:20
高级用户 Posts 247 Credits 846 From 湖南==》广东
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!
Floor2 vkill Posted 2006-11-19 02:35
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
Remember that challenge, and these are all mentioned in batch operations
Floor3 youxi01 Posted 2006-11-19 03:06
高级用户 Posts 247 Credits 846 From 湖南==》广东
It seems that I, a newbie, have opened the wrong post again!
The original has already had discussions!
http://www.cn-dos.net/forum/viewthread.php?tid=23568&fpage=1&highlight=%E5%8F%82%E4%B8%8E

However, the above calculation method has drawbacks (temporarily does not support floating-point number calculation), but it also has advantages. When processing particularly large numbers, the running efficiency is much higher.
Under the same circumstances, the code provided in the above post takes a long time to calculate 123456789101112131415161718192021222324252627282930*123456789101112131415161718192021222324252627282930, but the above code can finish it in two or three seconds
Floor4 zouzhxi Posted 2006-11-19 04:00
中级用户 Posts 177 Credits 430 From 广东深圳
If you change it to division, can you calculate pi? PI = 3.14...
Floor5 不得不爱 Posted 2006-11-19 04:49
超级版主 Posts 2,044 Credits 5,310 From 四川南充
Why does the code from the original poster say "operand not found. operand not found. Ah"?
Floor6 youxi01 Posted 2006-11-19 06:48
高级用户 Posts 247 Credits 846 From 湖南==》广东
There's no problem here for me!



As for the calculation of pi, using batch processing, it's difficult~ I think so.
Floor7 electronixtar Posted 2006-11-19 06:48
铂金会员 Posts 2,672 Credits 7,493
Directly simulating assembly, using bitwise operations may be a good idea
Floor8 不得不爱 Posted 2006-11-19 06:58
超级版主 Posts 2,044 Credits 5,310 From 四川南充
It turns out there was an error in set /a num%%i%2=!var:~%%i,1!, it should be: set /a num%%i%~2=!var:~%%i,1!
Floor9 youxi01 Posted 2006-11-19 07:11
高级用户 Posts 247 Credits 846 From 湖南==》广东
I can't figure out why "set /a num%%i%~2=!var:~%%i,1! " can prevent some errors?
Floor10 不得不爱 Posted 2006-11-19 22:49
超级版主 Posts 2,044 Credits 5,310 From 四川南充
Because the second parameter in call :test %str1% "" ex is "", set /a num%%i%~2=!var:~%%i,1! will automatically remove the "" in %2. Otherwise, set /a num%%i%2=!var:~%%i,1! is equivalent to set /a num%%i""=!var:~%%i,1!, can this not go wrong?
Floor11 不得不爱 Posted 2006-11-19 22:54
超级版主 Posts 2,044 Credits 5,310 From 四川南充
In addition, the carry should start from the lowest bit, otherwise it will also go wrong, because sometimes there will be multiple consecutive carries, then your algorithm will go wrong
Floor12 6622186 Posted 2007-04-05 11:27
高级用户 Posts 411 Credits 894
65536 multiplied by 65536 will truncate each digit.
Floor13 bjsh Posted 2007-04-05 22:15
银牌会员 Posts 621 Credits 2,000
I have written a division in the 26th floor here; The dividend can theoretically be arbitrarily large; the number of decimal places can theoretically be arbitrarily many; but it really doesn't work when trying 1 million digits; it will prompt that the output is too long; However, the situation where the divisor is greater than 10 to the ninth power has never been solved

http://www.cn-dos.net/forum/viewthread.php?tid=29097&fpage=5&highlight=&page=2
Floor14 flyinspace Posted 2007-04-05 23:36
银牌会员 Posts 517 Credits 1,206
Hehe, indeed. Simulating assembly will calculate faster. The method is also simpler.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023