How can I compute the range of signed and unsigned types

Mark Hahn hahn at coffee.psychology.mcmaster.ca
Wed Apr 18 14:22:42 EDT 2001


> > 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.
> 
> No, the C standard says nothing of the sort.

yes, it does, in section 5.2.4.2 (with an implementation's
version of the ranges in limits.h and float.h)

> All the C standard says is that
> 
> 1) sizeof (char)  == 1
> 2) sizeof (short) >= sizeof (char)
> 3) sizeof (int)   >= sizeof (short)
> 4) sizeof (long)  >= sizeof (int)
> 5) sizeof (long long) >= sizeof (long).

well, in addition, char requires >=8 bits, short >=16, int >=16,
long >=32, and floats range 1e+-37.

regards, mark hahn.


_______________________________________________
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf



More information about the Beowulf mailing list