From: Daniel Berger Date: 2006-02-16T02:47:58+09:00 Subject: Re: pack("l"), 64 bit question Yukihiro Matsumoto wrote: > List-Unsubscribe: > > Hi, > > In message "Re: pack("l"), 64 bit question" > on Thu, 16 Feb 2006 01:50:34 +0900, Daniel Berger writes: > > |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] > > Hmm, unpack("l") should have returned negative value unless "_" suffix > is supplied. > > matz. > Here's some more info that may or may not be useful: # 64 bit irb(main):004:0> "\377\377\377\377".unpack("l_") => [nil] irb(main):005:0> [-1].pack("l_") => "\377\377\377\377\377\377\377\377" irb(main):006:0> "\377\377\377\377\377\377\377\377".unpack("l_") => [-1] Regards, Dan