This is the mail archive of the gcc-help@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]
Other format: [Raw text]

RE: Shifting: what's going on?


Facundo Ciccioli wrote:

>     unsigned long long a;
>     unsigned s= 63;
>
>     a= (1 << s);

The problem is that 1 is a signed integer constant not an unsigned long long constant, and there's no mechanism to automatically spot that you really meant it to be an unsigned long long constant. So this code does mean compute a shift on a 32-bit integer then extend the result into a 64-bit variable. Try:

    a = (1ULL << s);

instead.

Rup.



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________


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