From: Philip Mak Date: 2003-04-09T05:46:03+09:00 Subject: packing signed long in a portable fashion Is there a way to pack() a signed long in a portable fashion (i.e. it should work on both little endian and big endian machines)? The pack() function has these options: 'l' => { :signed => true, :network => false } 'N' => { :signed => false, :network => true } But I cannot find an option that is { :signed => true, :network => true }! So if I pack with 'l', it won't work on different architectures. And if I pack with 'N', it won't allow negative numbers. For now, I think I have to pack with 'N', but add 2**32 before packing and subtract 2**32 after unpacking, but I think there ought to be a better way?