From: Joel VanderWerf Date: 2006-03-30T05:40:06+09:00 Subject: Re: unpack signed short in network (big-endian) byte order baumanj@gmail.com wrote: > Is there any particular reason why there is no format specifier in the > String.unpack method for unpacking a signed short in network byte > order? There seems only to be one for unsigned, which can then be > converted to signed with a proc like this: > > length = 16 > max = 2**length-1 > mid = 2**(length-1) > to_signed = proc {|n| (n >= mid) ? -((n ^ max) + 1) : n} > > It seems reasonable to add a format specifier to do this directly. > Thoughts? > I'd vote for that. Looks like you already found this thread :) http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/165774?165771-168359 -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407