Bit Shift with Int64

You must move the Int64 variable. I am parsing pseudo mathematical functions from a database file. The variables are uint32 or int32, so I put them in Int64 to handle them the same way without losing anything. In one of my treenodes, I need an Int64 bitrate.

Unfortunately, the shift operator does not apply to Int64. Is there a standard Int64 bit offset method that I don't know about?

//Int32 Example works
int a32 = 1;
int b32 = 2;
int c32 = a32 >> b32;

//Int64 Example does not compile
Int64 a64 = 1;
Int64 b64 = 2;
Int64 c64 = a64 >> b64; //invalid operator
+5
source share
2 answers

I believe that the right operand of the operator on the right side (in C #) always accepts int, even if the left operand is not int.

The official information is here in the C # Specification on MSDN .

+14
source

The number of bits to be shifted should be int.

For instance:

int shift = 3;
long foo = 123456789012345;
long bar = foo >> shift;
+9
source

All Articles