in reply to Re^3: comparison of packed signed integers
in thread comparison of packed signed integers

Yes, but the same holds true using 'l>'.

knoppix@Microknoppix:~$ perl -E ' > $pos = pack q{l>}, 10000; > say unpack q{B*}, $pos; > $neg = pack q{l>}, -10000; > say unpack q{B*}, $neg; > say $pos gt $neg ? q{Good} : q{Bad};' 00000000000000000010011100010000 11111111111111111101100011110000 Bad knoppix@Microknoppix:~$

I think that packing with 'N' or 'l>' will always produce the same results, it is unpacking where it makes a difference.

knoppix@Microknoppix:~$ perl -E ' > for ( -2147483648, -1, 0, 1, 2147483647, 4294967295 ) > { > say qq{$_:}; > say unpack q{B*}, pack q{N}, $_; > say unpack q{B*}, pack q{l>}, $_; > say q{-} x 32; > }; > ' -2147483648: 10000000000000000000000000000000 10000000000000000000000000000000 -------------------------------- -1: 11111111111111111111111111111111 11111111111111111111111111111111 -------------------------------- 0: 00000000000000000000000000000000 00000000000000000000000000000000 -------------------------------- 1: 00000000000000000000000000000001 00000000000000000000000000000001 -------------------------------- 2147483647: 01111111111111111111111111111111 01111111111111111111111111111111 -------------------------------- 4294967295: 11111111111111111111111111111111 11111111111111111111111111111111 -------------------------------- knoppix@Microknoppix:~$

However, I'm happy to be corrected if I'm wrong.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^5: comparison of packed signed integers
by BrowserUk (Patriarch) on Oct 30, 2011 at 12:33 UTC
    However, I'm happy to be corrected if I'm wrong.

    You're not wrong! Thanks for the reality check.

    It will only work with unsigned big-endian. I'll update my post above.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.