0

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?

6
  • Are you referring to MS-DOS or the command line interpreter that comes with Windows XP/Vista/7? Oct 11, 2012 at 15:47
  • cammand line interpreter
    – Sachin
    Oct 11, 2012 at 15:48
  • @Sachin - The command prompt is a 32-bit process. This means that an integer is its normal size.
    – Ramhound
    Oct 11, 2012 at 16:22
  • 4
    if powershell is an option, it's easiest: it will auto choose either int32 or int64 so this runs fine: powershell 10000000000 -ge 20000000000000
    – wmz
    Oct 11, 2012 at 16:28
  • I went ahead and remove the ms-dos tag since it clearly indicates NOT to use it for command prompt questions.
    – Ramhound
    Oct 11, 2012 at 16:44

1 Answer 1

1

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 strings
  • tmpX hold the number strings prefixed with 15 spaces
  • padX 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .