Aaron Patterson wrote:
> Hi everyone.  I'm porting some C code to pure ruby, and I would like to
> keep Ruby from turning my numbers in to Bignums.  Is that possible?
> 
> For example, in C:
> 
>   printf("number: %d\n", 0xd76aa478);
> 
> Prints "number: -680876936"

It's just another variation on pack/unpack, but with bit-struct (from RAA):

require 'bit-struct'

class C < BitStruct
  signed    :foo,   32
end

c = C.new
c.foo = 0xd76aa478

printf("number: %d\n", c.foo)
# ==> number: -680876936

-- 
      vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407