Range of values in C Int and Long 32 - 64 bits

Custodio picture Custodio · May 27, 2011 · Viewed 301.3k times · Source

I'm confused with range of values of Int variable in C.

I know that a 32bits unsigned int have a range of: 0 to 65,535. So long has 0 to 4,294,967,295

This is fine in 32bits machine. But now in 64bits machines all thing keep the same? Or maybe my int capacity is different?

I understand this questions as newbie, but I'm really confused. This method signature is not helping too. :)

unsigned long long int atomicAdd(unsigned long long int* address, unsigned long long int val);

Answer

Johannes Schaub - litb picture Johannes Schaub - litb · May 27, 2011

In C and C++ you have these least requirements (i.e actual implementations can have larger magnitudes)

signed char: -2^07+1 to +2^07-1
short:       -2^15+1 to +2^15-1
int:         -2^15+1 to +2^15-1
long:        -2^31+1 to +2^31-1
long long:   -2^63+1 to +2^63-1

Now, on particular implementations, you have a variety of bit ranges. The wikipedia article describes this nicely.