Connop, Tim wrote:
Is there a module or method of handling large hex numbers? I want to sort them into largest first order, it works fine for number of 8 characters or below, but anything above I get error messages:

Hexadecimal number > 0xffffffff non-portable at test.pl line 3.
Integer overflow in hexadecimal number at test 3.

#!/usr/bin/perl -w
@array=("3E1D302EDFDFDFDF", "3E1D", "4E1D302ECCCC6666", "4E1D302ECCCC6667","4E1D302DCCCC6666", "3E");
my @array= sort { hex($b) <=> hex($a) } @array;
foreach (@array) {
print "$_\n";
}
You could find the longest one and prefix zeros on the ones shorter
than the longest and then do a cmp instead of <=>.  You should be able
to either use map on a one-liner or make a second array with the new
strings in it.

There may also be possibilities using Math::BigInt.

--
  ,-/-  __      _  _         $Bill Luebkert   ICQ=162126130
 (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to