How can I compute the range of signed and unsigned types
Joe Griffin
joe.griffin at mscsoftware.com
Wed Apr 18 05:47:39 PDT 2001
I beg to differ. I know this list is mainly for Linux
users, but the original post was asking specifically about
different "types of machines" so I assume he
does not mean IA32/Linux.
CRAY systems use 46 or 64 bit integers. There
are also compiler options that can change the
definition of "int" on many computers. On an
NEC / SX-5 you can compile int to be 32 or 64 bits
I believe.
Here is a little "C" routine which may be used:
#include <stdio.h>
main()
{
printf("size of int is %4d \n",sizeof(int));
printf("size of Unsign int is %4d \n",sizeof( unsigned int));
printf("size of char is %4d \n",sizeof(char));
printf("size of float is %4d \n",sizeof(float));
printf("size of double is %4d \n",sizeof(double));
}
Regards,
Joe
> > How can I 'compute' the different sizes of types on the machine? to
> > prove that the values within limits.h are valid. I also would like to
> > do this for reals. Anyone have any tips - I'd appreciate it.
>
> Those sizes are defined for the C language. In order words, no matter
> if you're on a 32-bit machine or a 64-bit machine, an int is always
> going to be 32-bit and thus have the same numeric range because the
> standards say so. This goes for all the basic types, not just int's.
>
> Jag
More information about the Beowulf
mailing list