[NCLUG] simple way to determine 32 or 64 bit?

Tkil tkil at scrye.com
Mon Jun 11 14:36:42 MDT 2001


>>>>> "Mike" == Mike Loseke <mike at verinet.com> writes:

Mike> Does anyone know of a simple way to determine whether your
Mike> system is running 32 or 64-bit? Under Solaris this can be done
Mike> using "isainfo -v" but I've not been able to find any similar
Mike> method under Linux yet.

this may not qualify as "simple", but:

| #include <stdio.h>
| #include <limits.h>
| 
| int main ( int argc, char * argv [] )
| {
|     int n_bits = 0;
|     unsigned long m = ULONG_MAX;
| 
|     while (m)
|     { 
|         m >>= 1;
|         n_bits++;
|     }
| 
|     printf("%d\n", n_bits);
|     
|     return n_bits;
| }

anyone care to test this on a 64-bit system?

t.

p.s. also, take a look at /proc/mtrr ... if it exists, i think they
     always print pointers with full precision -- which should give
     you the size of pointers, at least.  again, i don't have a 64-bit
     system to check this on.



More information about the NCLUG mailing list