This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c/2614: Error when calculating with long long int
- To: <jacob dot schultz at barconet dot com>
- Subject: Re: c/2614: Error when calculating with long long int
- From: Bernd Schmidt <bernds at redhat dot com>
- Date: Mon, 23 Apr 2001 16:01:18 +0100 (BST)
- cc: <gcc-gnats at gcc dot gnu dot org>, <gcc-prs at gcc dot gnu dot org>, <gcc-bugs at gcc dot gnu dot org>
On 23 Apr 2001 jacob.schultz@barconet.com wrote:
> There seems to be a problem when calculating with long longs. In a program I need to mask a number of bits from a long long, but something goes wrong. The calculation
> ((1<<n)-1)&m returns zero when n is 32 or larger, even if bits are set in m. Both n and m are unsigned long long int.
Try "(((1ull<<n) - 1) & m)".
Bernd