Hey Guys,

Got a weird one for you all -- anyone know how to convert a Fixnum/Bignum
into a two's-complement byte array (in Ruby)?

Examples of what I'm looking to do using a non-existent Fixnum#to_byte_array
method:

65537.to_byte_array
# => [0,1,0,1]

35.to_byte_array
# => [35, 0]

Java equivalent:
http://download.oracle.com/javase/1.4.2/docs/api/java/math/BigInteger.html#toByteArray()

Thanks,
James

-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby

Reply via email to