Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #2441

Re: Packing and unpacking unsigned integers of arbitrary size as binary strings

From Brian Candler <b.candler@pobox.com>
Newsgroups comp.lang.ruby
Subject Re: Packing and unpacking unsigned integers of arbitrary size as binary strings
Date 2011-04-07 04:43 -0500
Organization Service de news de lacave.net
Message-ID <b9069dd06df1d33c8252f733f1008839@ruby-forum.com> (permalink)
References <BANLkTimL4u2=2quBF-qv0x2N7W7NJ8u9AQ@mail.gmail.com> <bd019337c95c63d99848674eb23125b0@ruby-forum.com>

Show all headers | View raw


Oh, I forgot to do the reverse:

>> bin = "\253T\251\214\353\037\n\322"
=> "\253T\251\214\353\037\n\322"
>> bin.unpack("H*").first.to_i(16)
=> 12345678901234567890

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Packing and unpacking unsigned integers of arbitrary size as binary strings "Aaron D. Gifford" <astounding@gmail.com> - 2011-04-06 23:56 -0500
  Re: Packing and unpacking unsigned integers of arbitrary size as binary strings Brian Candler <b.candler@pobox.com> - 2011-04-07 04:41 -0500
    Re: Packing and unpacking unsigned integers of arbitrary size as binary strings Brian Candler <b.candler@pobox.com> - 2011-04-07 04:43 -0500
      Re: Packing and unpacking unsigned integers of arbitrary size as binary strings "Aaron D. Gifford" <astounding@gmail.com> - 2011-04-07 11:30 -0500

csiph-web