Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Are you referring to MS-DOS or the command line interpreter that comes with Windows XP/Vista/7? –  Darth Android Oct 11 '12 at 15:47
    
cammand line interpreter –  Sachin Oct 11 '12 at 15:48
    
@Sachin - The command prompt is a 32-bit process. This means that an integer is its normal size. –  Ramhound Oct 11 '12 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 '12 at 16:28
    
What have you tried already? If %num1% gtr %num2%? –  Ƭᴇcʜιᴇ007 Oct 11 '12 at 16:38
show 2 more comments

1 Answer 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.