Packing a long binary integer in Ruby
Posted
by
user1056142
on Stack Overflow
See other posts from Stack Overflow
or by user1056142
Published on 2011-11-20T08:06:45Z
Indexed on
2011/11/21
1:52 UTC
Read the original article
Hit count: 494
I'm trying to send a very long binary integer over UDP (on the order of 200 bits). When I try to use Array's pack method, it complains the string I'm trying to convert is too large.
Am I going about this the wrong way?
ruby-1.8.7-p352 :003 > [0b1101001010101101111010100101010011010101010110010101010101010010010101001010101010101011101010101010101111010101010101010101].pack('i')
RangeError: bignum too big to convert into `unsigned long'
from (irb):3:in `pack'
from (irb):3
This number is supposed to represent a DNS query packet (this is for a homework assignment; we're not allowed to use any DNS libraries).
© Stack Overflow or respective owner