How to compare two numbers if they are greater than 32 bit integer in dos in a 32 bit system? The two numbers are the size of folders in bytes. Can somebody help me please?
1 Answer
The idea of techie007 is actually usable when using padded strings instead of numbers:
set num1=666123456789
set num2=123450123456789
set "tmp1= %num1%"
set "tmp2= %num2%"
set pad1="%tmp1:~-15%"
set pad2="%tmp2:~-15%"
if %pad1% gtr %pad2% …
In this code you can compare 2 numbers with up to 15 digits:
numX
hold the number stringstmpX
hold the number strings prefixed with 15 spacespadX
hold the last 15 characters in quotes —> padded number strings, now ready for comparison!
Better put this in a subroutine if you need to compare more numbers, or if applicable, sort the padded strings via the available sort
command.
MS-DOS
or the command line interpreter that comes with Windows XP/Vista/7?powershell
is an option, it's easiest: it will auto choose either int32 or int64 so this runs fine:powershell 10000000000 -ge 20000000000000