The sum of split values are still limited to the 32-bit limit (2,147,483,647) so neither the "low" nor the "high" can exceed it, but...
4-digit split allows for 21,476,983,953,647 (21 terabyte range).
5-digit split allows for 214,750,512,183,647 (214 terabyte range), etc...
I use similar code in for loops to combine sets of numbers above 32-bits and operate on them, but I also use VBScript sometimes for single large-number operations.
Code: Select all
@echo off&setlocal enabledelayedexpansion
:: 55 gigabyte number: 55,123,456,789
set num1=55123456789
:: 44 gigabyte number: 44,765,320,877
set num2=44765320877
:: Digit where split occurs. Must be negative. Padding must be same number of 0s as split.
set split=-5
set pad=00000
for %%a in (%num1% %num2%) do (
set num=%%a
set lead=%pad%!num:~%split%!
set /a low+=1!lead:~%split%!-1%pad%,high+=!num:~,%split%!+0
)
:: Now we have split and combined num1 and num2 into low (ten-thousands range) and high (above ten-thousands).
:: Multiply numbers by 1000, result of entire operation is the same as (num1+num2)*1000.
set /a low*=1000,high*=1000
set /a result=!low:~,%split%!+%high%
set result=%result%!low:~%split%!
echo: ^> Result: %result%
echo: ^> Should be: 99888777666000
pause
exit
The leading zero stripping prevents the hex/octal/decimal number error.
The +0 after high+= is just to prevent a missing operand error if there are no digits above 4 in any processed number.
Here's some limitation info on 4 and 5-digit splits:
Code: Select all
32-bit limit: 2,147,483,647
4-digit split:
low range max: allows for adding 214769 values (files) of 9999 (low-range bytes)
high range example: [21,474,836,47-,---] allows for adding 21474 values (files) of 1,000,000,000 (1 GB size)
5-digit split:
low range max: allows for adding 21475 values (files) of 99999 (low-range bytes)
high range example: [214,748,364,7--,---] allows for adding 214748 values (files) of 1,000,000,000 (1 GB size)
Quite acceptable boundaries.