Skip to content

Instantly share code, notes, and snippets.

@jmhodges
Created January 30, 2009 19:18
Show Gist options
  • Save jmhodges/55220 to your computer and use it in GitHub Desktop.
Save jmhodges/55220 to your computer and use it in GitHub Desktop.
# From http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/256730
module Endian
def self.big?
endianness == :big
end
def self.little?
endianness == :little
end
def self.endianness
x = 0xdeadbeef
endian_type = {
Array(x).pack("V*") => :little,
Array(x).pack("N*") => :big
}
endian_type[Array(x).pack("L*")]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment