long.MaxValue = 9223372036854775807
your value 1 = 18374686479671623680
your value 2 = 9259542123273814144
Your values are bigger than the signed long can hold. This is why you have to use unsigned.
Question
static long[] Mask1=
{
0xFF, 0xFF00, 0xFF0000, 0xFF000000,
0xFF00000000, 0xFF0000000000, 0xFF000000000000, 0xFF00000000000000
};
static long[] Mask2 =
{
0x101010101010101, 0x202020202020202, 0x404040404040404, 0x808080808080808,
0x1010101010101010, 0x2020202020202020, 0x4040404040404040, 0x8080808080808080
};
In Java, I can put these values into long[] just fine.
But in C#, I get that they cannot be 'convert to a long'.
I can only use a ulong in C#, but why when Java long and C# long have the same capacity? –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 no? Is there an extra specifier I need for the masks?
Specifically my errors are:
"Constant value `18374686479671623680' cannot be converted to a `long'"
Constant value `9259542123273814144' cannot be converted to a `long'
Solution
long.MaxValue = 9223372036854775807
your value 1 = 18374686479671623680
your value 2 = 9259542123273814144
Your values are bigger than the signed long can hold. This is why you have to use unsigned.
OTHER TIPS
You have to use an 'unchecked' cast in C# for the out-of-range values:
static long[] Mask1 = {0xFF, 0xFF00, 0xFF0000, 0xFF000000, 0xFF00000000, 0xFF0000000000, 0xFF000000000000, unchecked((long)0xFF00000000000000)};
static long[] Mask2 = {0x101010101010101, 0x202020202020202, 0x404040404040404, 0x808080808080808, 0x1010101010101010, 0x2020202020202020, 0x4040404040404040, unchecked((long)0x8080808080808080)};