What does the operator “<<” mean in C#?

前端 未结 9 1075
无人共我
无人共我 2020-12-05 22:57

I was doing some basic audio programming in C# using the NAudio package and I came across the following expression and I have no idea what it means, as i\'ve never seen the

相关标签:
9条回答
  • 2020-12-05 23:41

    The "<<" is a shift left operator. x << y shifts bit pattern x y position left.

    For example, if x was 0001 0101 and y was 1 then the result would be 0010 1010. It's like someone's pushed each bit left one.

    0 讨论(0)
  • 2020-12-05 23:47

    As a few people have pointed out already it is a shift operation.

    However It is worth noting that depending on whether the operand is a signed integral type or a unsigned integral type it will apply either an arithmetic or logical shift.

    See the bottom of this page on msdn.

    0 讨论(0)
  • 2020-12-05 23:50

    Shift left (and the counterpart, Shift right) moves the bits in the given direction.

    Shift left is more or less times 2, but faster

    Shift right is more or less divided by 2, but faster

    0 讨论(0)
提交回复
热议问题