4
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by GyanPP
0

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.

0

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

0

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

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

>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.

Votes + Comments
Agree!
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.