On Sat, 4 Aug 2001, Eric Lee Green wrote:

> This works fine on Intel machines, which are little-endian. I am
> wondering, though, what will happen when I try to run it on a Sun
> (which is big-endian)? Do bits have a pre-defined order?



Integer#[] is not dependent on endianness.

The only endian-dependent part of Ruby i can think of is Array#pack,
String#unpack, and even then, they are in a controlled way.

In RubyX11, I use this test for endianness (required for opening a X11
connection):

case [1].pack("L")
when "\0\0\0\1" # like 68k
        ByteOrder = "B"
when "\1\0\0\0" # like i386
        ByteOrder = "l"
else
        raise "Cannot determine byte order"
end



matju