in reply to Re^2: Why is pack("N",42949672965) giving me 00 00 00 05
in thread Why is pack("N",42949672965) giving me 00 00 00 05

... or even 0xFFFF_FFFF or 4_294_967_295 for that matter.


Give a man a fish:  <%-(-(-(-<

Replies are listed 'Best First'.
Re^4: Why is pack("N",42949672965) giving me 00 00 00 05
by Tux (Canon) on Feb 09, 2015 at 08:38 UTC

    Why not simply use -1?

    $ perl -MDP -we'DHexDump pack ("N", -1)' 0000 ff ff ff ff .... $ perl -MDP -we'DHexDump pack ("Q", -1)' 0000 ff ff ff ff ff ff ff ff ........

    Enjoy, Have FUN! H.Merijn
      Aside from the fact that N is suppose to take an unsigned integer, your very question demonstrates that -1 and 0xFFFF_FFFF pack differently.
        Aside from the fact that N is suppose to take an unsigned integer,

        Hm. pack takes a bunch of bits and interprets them in whatever way you tell if to:

        print unpack 'f', pack 'N', unpack 'N', pack 'f', 3.141592653589793238 +4626433832795;; 3.14159274101257
        your very question demonstrates that -1 and 0xFFFF_FFFF pack differently

        Que! Care to explain what you think you mean by that?

        Neither I nor Perl can see any difference:

        print pack('N', -1) eq pack('N', 0xffffffff) ? 'Same' : 'Different';; Same

        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". I'm with torvalds on this
        In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
Re^4: Why is pack("N",42949672965) giving me 00 00 00 05
by isync (Hermit) on Feb 09, 2015 at 18:23 UTC
    @AnomalousMonk: well, didn't know that. but never liked the underscore notation for numbers, anyway... :)