in reply to comparison of packed signed integers
Updated: To reflect the reality check from johngg below.
Comparison of packed integer will only work if they are unsigned (or all positive or all negative) and packed in big-endian (Network) order:
$belo = pack 'N', 10000; $behi = pack 'N', 20000; $ben = pack 'N', 123 +45;; $belo lt $ben && $behi gt $ben and print 'Works';; Works
Not if they are packed in little-endian (VAX) order:
$lelo = pack 'V', 10000; $lehi = pack 'V', 20000; $len = pack 'V', 123 +45;; $lelo lt $len && $lehi gt $len and print 'Works';;
The same thing for packed signed integers (but only works if the numbers are all positive or all negative):
$bello = pack 'l>', 10000; $belhi = pack 'l>', 20000; $beln = pack 'l> +', 12345;; $bello lt $beln && $belhi gt $beln and print 'Works';; Works $lello = pack 'l<', 10000; $lelhi = pack 'l<', 20000; $leln = pack 'l< +', 12345;; $lello lt $leln && $lelhi gt $leln and print 'Works';;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: comparison of packed signed integers
by johngg (Canon) on Oct 30, 2011 at 11:36 UTC | |
by BrowserUk (Patriarch) on Oct 30, 2011 at 12:00 UTC | |
by johngg (Canon) on Oct 30, 2011 at 12:28 UTC | |
by BrowserUk (Patriarch) on Oct 30, 2011 at 12:33 UTC | |
|
Re^2: comparison of packed signed integers
by gerleu (Novice) on Oct 30, 2011 at 12:06 UTC | |
by BrowserUk (Patriarch) on Oct 30, 2011 at 12:16 UTC | |
by gerleu (Novice) on Oct 30, 2011 at 12:36 UTC | |
by gerleu (Novice) on Oct 30, 2011 at 12:51 UTC | |
by BrowserUk (Patriarch) on Oct 30, 2011 at 12:39 UTC |