Endianess of the underlying platform

Does ruby provide a global or a method call to determine the endianess
of the underlying platform?

This is what I cooked up, but I’m wondering if there is a ruby way of
doing this.

BIG_ENDIAN = [0xFF00].pack(‘S’) == [0xFF00].pack(‘n’)

Blessings,
TwP

On Wed, 25 Oct 2006, Tim P. wrote:

Blessings,
TwP

you could at least have more fun

little_endian = [42].pack(‘i’)[0] == 42

:wink:

-a

On 10/24/06, [email protected] [email protected] wrote:

Blessings,
TwP

you could at least have more fun

little_endian = [42].pack(‘i’)[0] == 42

:wink:

Very tricksie of you! I’m always amazed at how your mind operates.

TwP

On Oct 24, 2006, at 4:40 PM, Tim P. wrote:

Does ruby provide a global or a method call to determine the endianess
of the underlying platform?

This is what I cooked up, but I’m wondering if there is a ruby way of
doing this.

BIG_ENDIAN = [0xFF00].pack(‘S’) == [0xFF00].pack(‘n’)

Beware, some versions of ruby shipped with OS X have a broken pack
where the endianness is swapped.


Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

On 11/16/06, Francis C. [email protected] wrote:

BIG_ENDIAN = [0xFF00].pack(‘S’) == [0xFF00].pack(‘n’)

Beware, some versions of ruby shipped with OS X have a broken pack
where the endianness is swapped.
Kinky. Is it a bug, or a hack intended to make PowerPCs look like Intel
chips?

Bug. It was fixed in a later OS update, IIRC.

-austin

On Nov 16, 2006, at 5:42 AM, Austin Z. wrote:

On 11/16/06, Francis C. [email protected] wrote:

On 11/15/06, Eric H. [email protected] wrote:

Beware, some versions of ruby shipped with OS X have a broken pack
where the endianness is swapped.
Kinky. Is it a bug, or a hack intended to make PowerPCs look like
Intel
chips?

Bug. It was fixed in a later OS update, IIRC.

Yes. Apple cross-compiled ruby from Intel to PPC and Ruby assumes
the source and target architectures have the same endianness.


Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

Eric H. wrote:

On Nov 16, 2006, at 5:42 AM, Austin Z. wrote:

Bug. It was fixed in a later OS update, IIRC.

Yes. Apple cross-compiled ruby from Intel to PPC and Ruby assumes the
source and target architectures have the same endianness.

Sounds like a bug in Ruby’s build to me…

On 11/15/06, Eric H. [email protected] wrote:

Beware, some versions of ruby shipped with OS X have a broken pack
where the endianness is swapped.

Kinky. Is it a bug, or a hack intended to make PowerPCs look like Intel
chips?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs