If you use integer in C++, you should be careful. Because the integer width is limited. For example, an short int in Cpp is 16bits. An int is no shorter than short integer. A long integer is 32 bits. I just do a test on i686 GNU/Linux. Here is the result.
short a ;
> a^14 = 16384
> a^15 = -32768
> a^16 = 0
int a ;
> a^30 = 1073741824
> a^31 = -2147483648
> a^32 = 0
long a ;
> a^30 = 1073741824
> a^31 = -2147483648
> a^32 = 0
unsigned short a ;
> a^14 = 16384
> a^15 = 32768
> a^16 = 0
unsigned int a ;
> a^30 = 1073741824
> a^31 = 2147483648
> a^32 = 0
unsigned long a ;
> a^30 = 1073741824
> a^31 = 2147483648
> a^32 = 0