in reply to Re^2: Converting negative number to binary with specific width
in thread Converting negative number to binary with specific width

what os the is use of pack 'v' for?
  • Comment on Re^3: Converting negative number to binary with specific width

Replies are listed 'Best First'.
Re^4: Converting negative number to binary with specific width
by Anonymous Monk on Nov 03, 2015 at 07:35 UTC

    what os the is use of pack 'v' for?

    The documentation explains it :)

    v An unsigned short (16-bit) in "VAX" (little-endian) order. V An unsigned long (32-bit) in "VAX" (little-endian) order.
      do you have to use it? Isn't unpack 'b10' enough?

        Try it and see. What result do you get? Are you happy with it? If yes, then you're done! (Of course, I'm not saying there is no other possible pack/unpack/reverse/sprintf/substr/whatever incantation that would do as well or better; see Convert ASCII string to 7-bit binary string for a recent, eerily similar discussion.)


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