c/2614: Error when calculating with long long int
julian@YoMama.Flewid.COM
julian@YoMama.Flewid.COM
Mon Apr 23 07:37:00 GMT 2001
Hi
> 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.
> I've attached an example which illustrates the pwoblem.
The number 1 is of type int, so you get a zero if the left shift count is
larger than 31. Use a "ll" suffix to change the type to long long.
Julian
More information about the Gcc-bugs
mailing list