An unsigned long(9999999000) returns 1410064408.
Any explanation to it?

What do you mean "returns" ?

What do you mean "returns" ?

returns in the sense the value returned when the number 9999999000 is typecasted into unsigned long is 1410064408.
I wanted to know why this happens.

a 32-bits unsigned long can hold a number no larger then 2^32 = 4294967296, so it'll overflow and become zero again.
So if you do 9999999000 % (mod) 4294967296 = 1410064408

To specify a 64-bit integral (long long) type, use the LL or ll suffix.

..
std::cout << 9999999000LL;
..

>To specify a 64-bit integral (long long) type, use the LL or ll suffix.
However, note that long long is not standard C++ yet (C++0x is nearing completion though), so you might encounter either complete failure or a difference in the details with various compilers.

commented: Agree! +6

Great! thanks a lot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.