RE: Shifting: what's going on?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux