On Sat, Jun 23, 2007 at 10:55:06PM +0900, akbarhome wrote: > Is there anyway in ruby to detect type of endianness of machine? Thank > you. pack/unpack should take care of that for you. I whipped up this sample. Also available from pastie http://pastie.caboo.se/72945 % cat endian-check.rb #!/usr/bin/env/ruby require 'rbconfig' include Config x = 0xdeadbeef endian_type = { Array(x).pack("V*") => :little, Array(x).pack("N*") => :big } puts "#{CONFIG['arch']} is a #{endian_type[Array(x).pack("L*")]} endian machine" And here's some results from various machines % ruby endian-check.rb i686-darwin8.9.1 is a little endian machine % ruby endian-check.rb x86_64-openbsd4.0 is a little endian machine % ruby endian-check.rb powerpc-darwin8.0 is a big endian machine % ruby endian-check.rb i386-linux is a little endian machine enjoy -jeremy -- ======================================================================== Jeremy Hinegardner jeremy / hinegardner.org