Unix Programming - Re: common solution for Linux, Solaris, HP-UX and AIX to get whether ?system is 32 bit

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > December 2007 > Re: common solution for Linux, Solaris, HP-UX and AIX to get whether ?system is 32 bit





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: common solution for Linux, Solaris, HP-UX and AIX to get whether ?system is 32 bit
Mark Hobley

2007-12-21, 7:22 pm

Aditya <adityagupta.18@gmail.com> wrote:

> So, please help me out with a common solution(may be a shell script),
> which tells me that my OS is 32-bit or 64-bit.


To do this programmatically, (not from a shell script):

Define an integer of value 4294967295 then compare it to an unsigned
value of -1. If it matches, then the platform is 32 bit.

A 64 bit platform would not cause a match here, because the minus bit
would be stored in the more significant doubleword.

Note I hope that my "twos compliment" maths is right. (I pulled these
numbers from out of my head, so I haven't actually done any calculations
here). If I am wrong, then I am sure that someone will follow up with
corrected values.

Mark.

--
Mark Hobley
393 Quinton Road West
QUINTON
Birmingham
B32 1QE

Email: markhobley at hotpop dot donottypethisbit com

http://markhobley.yi.org/

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com