> -----Original Message-----
> From: Lyle Johnson [mailto:lyle / users.sourceforge.net] 
> Sent: Monday, November 17, 2003 2:47 PM
> To: ruby-talk ML
> Subject: Re: pack bug on 64-bit ruby
> 
> 
> Daniel Berger wrote:
> 
> > Looks like there's a 64-bit related bug in pack():
> > 
> > irb(main):007:0> [-1].pack("V")
> > RangeError: integer 18446744073709551615 too big to convert to 
> > `unsigned int'
> >         from (irb):7:in `pack'
> >         from (irb):7
> 
> If Array#pack is supposed to output a four-character string for the 
> *unsigned* long value, I think maybe this shouldn't work for 64-bit. 
> You're passing in a value of -1, which is 2**64 - 1 when 
> represented as 
> an unsigned long on a 64-bit machine. You can't pack that into four 
> characters (bytes).
> 
> Out of curiosity, what happens if you instead try this?
> 
>      [-1].pack("L_")
> 
> Note the trailing underscore. If I read the code right, this 
> should do 
> the right thing.

Thanks Lyle - that seems to work although (as expected I think) it does
it in 8 bytes.

The question I have now then is, if I've got code that uses
[-1].pack("V"), how should I handle this on 64 bit platforms?  Is there
a way to tell the bit-ness of Ruby from within Ruby?  Perhaps a
RUBY_BITNESS constant?  Or is there some sort of "cross-bitness"
approach I can use?

Regards,

Dan