Simple way to detect 32bit vs 64bit?

Anyone have simple means for checking if the running arch is 32bit or
64bit?

ruby-1.9.2-p0 > RUBY_PLATFORM
=> “x86_64-darwin10.4.0”

On 01/28/2011 12:31 PM, Intransition wrote:

Anyone have simple means for checking if the running arch is 32bit or
64bit?

1.size => 4 on 32 bit, 8 on 64 bit.

-Justin

On Jan 28, 3:15pm, Justin C. [email protected] wrote:

On 01/28/2011 12:31 PM, Intransition wrote:> Anyone have simple means for
checking if the running arch is 32bit or

64bit?

1.size => 4 on 32 bit, 8 on 64 bit.

As Park H. pointed out to me, that’s not reliable. Use this
instead:

[‘a’].pack(‘P’).length > 4 ? “64Bit” : “32Bit”

Regards,

Dan

1 Like

Awesome, thanks.