This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
why does EGCS tell me 1 << 64 = 4294967296?
- To: egcs-bugs at cygnus dot com
- Subject: why does EGCS tell me 1 << 64 = 4294967296?
- From: Brians0 at aol dot com
- Date: Sun, 9 Aug 1998 07:39:55 EDT
I'm using EGCS 1.0.3 with Cygwin32 B19.1 on Windows 95, which has 64-bit
unsigned long longs. I've noticed that the result of
"static_cast<unsigned long long>(1) << 64" is 2^31. Is this what it is
supposed to be? I would expect this to result in zero (0), since it
would/should shift out all nonzero bits. Am I incorrect, or is EGCS?
When i build and run the code below, the output is:
static_cast<unsigned long long>(1)
<< (sizeof(unsigned long long) * 8) =
4294967296
---------------------------------------------------------
int main()
{
cout << "static_cast<unsigned long long>(1)" << endl
<< " << (sizeof(unsigned long long) * 8) =" << endl
<< " " << (static_cast<unsigned long long>(1)
<< (sizeof(unsigned long long) * 8)) << endl;
return 0;
}