From: ara.t.howard@... Date: 2006-02-16T02:03:24+09:00 Subject: Re: pack("l"), 64 bit question On Thu, 16 Feb 2006, Daniel Berger wrote: > Hi all, > > Ruby 1.8.4 > Solaris 10 > > Is this correct? > > # 32 bit > irb(main):002:0> [-1].pack("l") > => "\377\377\377\377" > irb(main):003:0> "\377\377\377\377".unpack("l") > => [-1] > > # 64 bit > irb(main):002:0> [-1].pack("l") > => "\377\377\377\377" > irb(main):003:0> "\377\377\377\377".unpack("l") > => [4294967295] > > Regards, > > Dan btw. this is useful for me irb(main):008:0> to_bin = lambda{|s| '[ ' << s.unpack('c*').map{|b| '%8.8b' % b}.join(' ') << ' ]'} => # irb(main):009:0> to_bin[ [-1].pack("l") ] => "[ 11111111 11111111 11111111 11111111 ]" irb(main):010:0> to_bin[ [-1].pack("i") ] => "[ 11111111 11111111 11111111 11111111 ]" irb(main):011:0> to_bin[ [1].pack("l") ] => "[ 00000001 00000000 00000000 00000000 ]" irb(main):012:0> to_bin[ [1].pack("i") ] => "[ 00000001 00000000 00000000 00000000 ]" -a -- judge your success by what you had to give up in order to get it. - h.h. the 14th dali lama cat a.rb