Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > How I can find out on which platform I am running (32/64 bits)?

Reply
Thread Tools

How I can find out on which platform I am running (32/64 bits)?

 
 
Joachim Just
Guest
Posts: n/a
 
      06-22-2005

I wonder whether within ruby there is a method to find out on which
platform my application is running.

Unfortunately, the application has to know if it is a 32-bit or 64-bit
system.

Any hints are highly appreciated.

Joachim Just
--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
 
Reply With Quote
 
 
 
 
Ara.T.Howard@noaa.gov
Guest
Posts: n/a
 
      06-22-2005
On Wed, 22 Jun 2005, Joachim Just wrote:

>
> I wonder whether within ruby there is a method to find out on which platform
> my application is running.
>
> Unfortunately, the application has to know if it is a 32-bit or 64-bit
> system.
>
> Any hints are highly appreciated.


untested, but

[42].pack('L').size * 8 # => 32

this should be the number of bits per long.

you may also be able to get something from Config::CONFIG

hth.

-a
--
================================================== =============================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| My religion is very simple. My religion is kindness.
| --Tenzin Gyatso
================================================== =============================

 
Reply With Quote
 
 
 
 
WATANABE Hirofumi
Guest
Posts: n/a
 
      06-22-2005
Hi,

"Joachim Just" <> writes:

> I wonder whether within ruby there is a method to find out on which
> platform my application is running.
>
> Unfortunately, the application has to know if it is a 32-bit or 64-bit
> system.
>
> Any hints are highly appreciated.



64-bit % ruby -ve 'p [0].pack("l!").size'
ruby 1.9.0 (2005-05-31) [x86_64-netbsd]
8

32-bit % ruby -ve 'p [0].pack("l!").size'
ruby 1.9.0 (2005-06-13) [i386-linux]
4

--
eban


 
Reply With Quote
 
Daniel Berger
Guest
Posts: n/a
 
      06-22-2005
WATANABE Hirofumi wrote:
> Hi,
>
> "Joachim Just" <> writes:
>
>
>>I wonder whether within ruby there is a method to find out on which
>>platform my application is running.
>>
>>Unfortunately, the application has to know if it is a 32-bit or 64-bit
>>system.
>>
>>Any hints are highly appreciated.

>
>
>
> 64-bit % ruby -ve 'p [0].pack("l!").size'
> ruby 1.9.0 (2005-05-31) [x86_64-netbsd]
> 8
>
> 32-bit % ruby -ve 'p [0].pack("l!").size'
> ruby 1.9.0 (2005-06-13) [i386-linux]
> 4


That doesn't tell me much on Solaris:

>ruby -ve 'p [0].pack("l!").size'

ruby 1.8.2 (2004-12-25) [sparc-solaris2.10]

Ara's approach should work fine, though.

Finding the bitness of Ruby itself is easy. Finding a cross platform
way to find the bitness of the OS itself is another matter. I'm not
sure what the OP is after.

If anyone knows of a good, cross-platform way of finding the bitness of
the OS itself, I'd like to know that myself.

Regards,

Dan






 
Reply With Quote
 
Charles Mills
Guest
Posts: n/a
 
      06-22-2005
Daniel Berger wrote:
> WATANABE Hirofumi wrote:
> > Hi,
> >
> > "Joachim Just" <> writes:
> >
> >
> >>I wonder whether within ruby there is a method to find out on which
> >>platform my application is running.
> >>
> >>Unfortunately, the application has to know if it is a 32-bit or 64-bit
> >>system.
> >>
> >>Any hints are highly appreciated.

> >
> >
> >
> > 64-bit % ruby -ve 'p [0].pack("l!").size'
> > ruby 1.9.0 (2005-05-31) [x86_64-netbsd]
> > 8
> >
> > 32-bit % ruby -ve 'p [0].pack("l!").size'
> > ruby 1.9.0 (2005-06-13) [i386-linux]
> > 4

>
> That doesn't tell me much on Solaris:
>
> >ruby -ve 'p [0].pack("l!").size'

> ruby 1.8.2 (2004-12-25) [sparc-solaris2.10]
>
> Ara's approach should work fine, though.
>
> Finding the bitness of Ruby itself is easy. Finding a cross platform
> way to find the bitness of the OS itself is another matter. I'm not
> sure what the OP is after.
>
> If anyone knows of a good, cross-platform way of finding the bitness of
> the OS itself, I'd like to know that myself.
>
> Regards,
>
> Dan


irb(main):001:0> [1].pack('L')
=> "\001\000\000\000"
irb(main):002:0> [0x01020304].pack('L')
=> "\004\003\002\001"

So I'm on a little endian machine.

-Charlie

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
FAQ 8.1 How do I find out which operating system I'm running under? PerlFAQ Server Perl Misc 0 03-07-2011 05:00 PM
does java program run on 64-bit platform as fast as on 32-bit platform jcc Java 15 05-12-2006 08:52 AM
How can I find out which .net version I'm running? =?Utf-8?B?SmVyZW15?= ASP .Net 2 04-10-2004 07:46 AM
How can I convert the C6.0 program of OS/2 platform TO a program in windows2000/xp platform? Coca C Programming 15 01-14-2004 04:44 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57