I have this code.
#include
int main()
{
unsigned long int i = 1U << 31;
std::cout << i << std::endl;
unsigned lon
I think it is compiler dependent .
It gives same value
2147483648
2147483648
on my machiene (g++) .
Proof : http://ideone.com/cvYzxN
And if overflow is there , then because uwantsum
is unsigned long int
and unsigned values are ALWAYS positive , conversion is done from signed to unsigned by using (uwantsum)%2^64
.
Hope this helps !