From: Brian Candler Date: 2009-02-16T05:52:45+09:00 Subject: Re: Ruby-newbie Terje Haarstad wrote: >> sum = buff[0] + buff[1] + buff[2] + buff[3] >> svar = [sum & 0xffffffff].pack("I") > > Why do u have to use sum & 0xffffffff? an error occour > (`pack': bignum too big to convert into `unsigned long' (RangeError) > from vortex0.rb:16) if i DONT use 0xfffffffff while use s.gets > but why do they conflict with each other? Ruby numbers don't wrap around - they can grow indefinitely large. Sometimes the four random 32-bit numbers add up to a 33-bit number. In this case, the server is expecting you to truncate the result to 32 bits. If you don't truncate explicitly, Array#pack will abort because the number you're asking it to fit into a 32-bit space is too big. HTH, Brian. -- Posted via http://www.ruby-forum.com/.