1

i've got the following batch script which calcuates a number based on a few things, its a rather big number however, This is what it should generate(example)76561197960287930 not more not less.

@echo off

if NOT %1a == a goto recurse
reg query HKCU\Software\Valve\Steam\Users > users.tmp
echo.

echo  
for /f "skip=1 delims=\ tokens=6" %%i in (users.tmp) do call %0 %%i
del users.tmp
echo  

pause>nul
goto end

:recurse

set SID=%1
set /A SID=SID/2
set /A SID1=SID*2
set STEAMBIT=0
if NOT %SID1% == %1 set STEAMBIT=1


    echo UserID: %SID%
    echo %SID% > userid.txt
        SET /A Result = ( %SID% * 2 ) + ( %STEAMBIT% + 76561197960265728 ) 
    echo %result% > useridresult.txt
    goto end

:end

exit

Is there a fix and or workaround? thanks

marceltje
  • 107
  • 1
  • 7
  • 2
    From the Set /A documentation: The numbers must all be within the range of 32 bit signed integer numbers (-2,147,483,648 through 2,147,483,647) to handle larger numbers use PowerShell or VBScript. – FloatingKiwi Sep 06 '16 at 17:12

1 Answers1

2

The maximum positive number that can be managed in "32 bits of precision" is 2147483647 (obtained via set /A 0x7FFFFFFF), so if you want to perform operations with more digits, just split the maximum number of digits in chunks of the appropriate size accordingly to the desired operation. For example, if you want to perform multiplications, then split the large number in groups of 4 digits (because 9999x9999 fits in 32-bits, but 99999x99999 does not). You may review a further description of this method at this answer.

However, this problem is very simple: you just want to add a large (17 digits) number to another one, so the result can be obtained in just two parts of 9 digits each:

@echo off
setlocal

set SID=%1
set /A "STEAMBIT=SID&1, SID=SID/2"

    echo UserID: %SID%   SteamBit: %STEAMBIT%
    SET /A Low = ( %SID% * 2 ) + ( %STEAMBIT% + 960265728 ),  High = Low / 1000000000 + 76561197
    echo Result: %High%%Low:~-9%

This method gives right results with SID numbers up to 999999999.

Community
  • 1
  • 1
Aacini
  • 59,374
  • 12
  • 63
  • 94