From: matz@... (Yukihiro Matsumoto) Date: 2002-06-12T01:49:54+09:00 Subject: Re: pack()ing Bignums Hi, In message "pack()ing Bignums" on 02/06/12, Dan Debertin writes: |I have a 128-bit Bignum that I need to pack into a binary string in |order to pass it to MD5.digest(). But there doesn't appear to be a |format for Array#pack that would accommodate such a large number; the |biggest appears to be "L", which is only a quarter the size I need. | |What's the best way to do this? Perhaps not as efficient as you expect: a) b = 128-bit bignum value data = [] 4.times{|i| data.unshift (b>>i*32)&0xffffffff } data.pack("NNNN") b) [sprintf("%0128b", b)].pack("B*") matz.