From: Jim Freeze Date: 2005-05-24T03:39:29+09:00 Subject: Re: Endian packing errors. * Brian Mitchell [2005-05-24 03:25:24 +0900]: > On 5/23/05, Jim Freeze wrote: > > * Brian Mitchell [2005-05-24 02:53:52 +0900]: > > > > > I have a number I must convert to a network long. I have been using > > > this thus far with success: > > > > > > [number].pack("N") > > > > > > for 65 it should return "\000\000\000A". It does so on my linux boxes, > > > an iMac with 10.3 but on my Powerbook with 10.4 it returns the reverse > > > "A\000\000\000". What is causing this. Did Apple mess up yet again > > > with including ruby? Could someone duplicate this on tiger? On my PowerBook with Ruby 1.8.2, I get: irb(main):001:0> [65].pack('N') => "\000\000\000A" irb(main):002:0> [65].pack('n') => "\000A" The "A\000\000\000" is not making sense to me. Sorry I don't have Tiger installed to compare with. > > Hmm, What do your machines (specifically the iMac) return for this: > > > > BigEndian = (0 == [1].pack('l')[0]) > PB(G4): true > iMac(G5): true > Linux(x86): false > > LittleEndian = (1 == [1].pack('l')[0]) > PB(G4): false > iMac(G5): false > Linux(x86): true -- Jim Freeze Ruby: I can explain it to ya but I can't understand it fer ya.