Bitwise operation on long
See http://msdn.microsoft.com/en-en/library/aa664674%28v=vs.71%29.aspx .
If the literal suffix has not, it is first of these types, which can be represented by its value:
int
,uint
,long
,ulong
.
You have
0xFFFFFFFFFFFFFC00
but Int64.Max:
0x7FFFFFFFFFFFFFFF
therefore it is long
not large enough, but ulong
taken as a literal type.
Now you have the left side of a Int64
which is signed, and on the right side you have ulong
, however, no overload &=
that accepts this combination, resulting in an error.
source to share
itag
is long. 0xFFFFFFFFFFFFFC00
- ulong. You are trying to mix both in a statement &=
that doesn't work.
Why is your literal ulug? MSDN says :
If the literal has no suffix, it is the first of these types in which its value can be represented: int, uint, long, ulong.
Since the number is too large for an int, uint, or long, your literal becomes ulong.
You have two options, either declare itag
as ulong as others have suggested, or (bitwise) convert your literal to long:
itag &= unchecked((long)0xFFFFFFFFFFFFFC00);
This will overflow your ulong to a (negative) long.
source to share
Section 7.11.1 Boolean Integer Operators of the C # Language Specification read:
Predefined integer logical operators:
int operator & (int x, int y);
uint operator & (uint x, uint y);
long operator & (long x, long y);
ulong operator & (ulong x, ulong y);
As you can see, there long
is no predefined operator between (which is just an alias for Int64
) and ulong
, hence the error.
source to share