Forum: Ruby How to check endianess using ruby?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Flower B. (Guest)
on 2008-12-19 06:42
(Received via mailing list)
Hi,

What's the right way to check the endianess(big/little endian) of the
machine
on which the ruby code run?

Thanks
Jan
Heesob P. (Guest)
on 2008-12-19 07:11
(Received via mailing list)
Hi,

2008/12/19 Xie H. <removed_email_address@domain.invalid>:
> Hi,
>
> What's the right way to check the endianess(big/little endian) of the machine
> on which the ruby code run?
>
[1].pack('S')[0]==1 ? 'little' : 'big'

Regards,
Park H.
Flower B. (Guest)
on 2008-12-19 07:55
(Received via mailing list)
* Heesob P. <removed_email_address@domain.invalid> [2008-12-19 14:02:41 +0900]:

> Hi,
>
> 2008/12/19 Xie H. <removed_email_address@domain.invalid>:
> > Hi,
> >
> > What's the right way to check the endianess(big/little endian) of the machine
> > on which the ruby code run?
> >
> [1].pack('S')[0]==1 ? 'little' : 'big'

cool thanks :)
This topic is locked and can not be replied to.