Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Operator << cannot be applied to operands of type long and long

Tags:

c#

bit-shift

I am trying to use the << operator on a long, like so:

((long) num3) << ( 2 + (long) num4)))

This gives me the following error:

Operator << cannot be applied to operands of type long and long.

If I don't cast num4 to a long, there is no error. However, I cannot keep it as an int. Is there any other way around this?

like image 438
hurnhu Avatar asked Nov 07 '14 19:11

hurnhu


1 Answers

The right operand has to be an int, not a long. It wouldn't make sense to use a long as the number of bits to shift, since integral types in C# never have more than 64 bits.

like image 64
Thomas Levesque Avatar answered Oct 11 '22 23:10

Thomas Levesque