Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » Time for little quiz!
Re: Time for little quiz! [message #2294 is a reply to message #2292] Thu, 06 April 2006 16:17 Go to previous messageGo to previous message
victorb is currently offline  victorb
Messages: 78
Registered: December 2005
Location: Nice, France
Member
Graeme,

If I understand your previous topic well, you are stating that there might be an inconsistency between GCC and VC because they do not handle integer the same way and you are afraid this might cause errors with "(-q >> 31) & 1".

However if you look at the following URL:
http://msdn2.microsoft.com/en-US/library/7x62187h(VS.80).aspx
You will see that VC handle right shifts the same way as GCC by etending the sign bit (for negative number as "-q").

VC:
"Right shifts preserve the sign bit. When a signed integer shifts right, the most-significant bit remains set. When an unsigned integer shifts right, the most-significant bit is cleared."

GCC:
"Signed >> acts on negative numbers by sign extension."

Victor
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: STL multimap
Next Topic: explanation of c++ typedef line
Goto Forum:
  


Current Time: Sat Jul 05 07:26:23 CEST 2025

Total time taken to generate the page: 0.04062 seconds