Getting my head round pack

I have this problem with pack. In a function I am using I have to use

tempdata = [data].pack(“i”) # This line works on PowerPC

or

tempdata = [data].pack(“i”).reverse # This line works on Intel

where data is a number (integer). I’ve tried some of the other pack
options but they dont seem to work. Is there a single option I could be
using?

Try using pack(“n”) instead.

http://www.rubycentral.com/book/ref_c_array.html#Array.include_qm

-austin
– Austin Ziegler, austin@halostatue.ca on 2002.10.18 at 10.13.50

···

On Fri, 18 Oct 2002 18:24:15 +0900, Peter Hickman wrote:

I have this problem with pack. In a function I am using I have to
use

tempdata = [data].pack(“i”) # This line works on PowerPC

or

tempdata = [data].pack(“i”).reverse # This line works on Intel

where data is a number (integer). I’ve tried some of the other
pack options but they dont seem to work. Is there a single option
I could be using?

Austin Ziegler wrote:

Try using pack(“n”) instead.

Thanks. I’ll try that when I get home