From: "Iñaki Baz Castillo" Date: 2010-01-15T18:32:22+09:00 Subject: Re: How to know the OS architecture (32 or 64 bits)? El Viernes, 15 de Enero de 2010, Rob Biedenharn escribió: > On Jan 14, 2010, at 6:12 PM, Iñaki Baz Castillo wrote: > > Hi, is there a reliable way under Ruby to know the OS architecture > > (32 or 64 > > bits)? > > > > I've just found RUBY_PLATFORM constant which returns "x86_64-linux" > > under 64 > > bits, however it doesn't send very reliable for me. > > > > I need a way working under Linux and BSD. Thanks for any suggestion. > > You can use Fixnum#size to get number of bytes for a Fixnum and > multiply by 8 bits/byte: > > irb(main):001:0> 1.size * 8 > => 64 > irb(main):002:0> RUBY_PLATFORM > => "x86_64-linux" > > irb> 1.size * 8 > => 32 > irb> RUBY_PLATFORM > => "universal-darwin9.0" It's really good! Thanks a lot. -- Iñaki Baz Castillo