From: Rob Biedenharn Date: 2010-01-15T09:35:30+09:00 Subject: Re: How to know the OS architecture (32 or 64 bits)? 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. > > -- > Iņaki Baz Castillo > 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" I think it's reliable. (Although I guess there could be a 32-bit ruby running on a 64-bit platform.) -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com