This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

why does EGCS tell me 1 << 64 = 4294967296?


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;
	}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]