【问题标题】:How to bitwise shift in VB.NET?如何在 VB.NET 中按位移位?
【发布时间】:2010-11-27 21:46:37
【问题描述】:

如何在 VB.NET 中按位右移/左移?它甚至有operators,还是我必须使用一些实用方法?

【问题讨论】:

  • 没错there mate,就在您发布的链接的列表中!

标签: vb.net operators bit-manipulation bit-shift


【解决方案1】:

自 2003 年以来,VB.NET 已经有了位移运算符(<<>>)。

【讨论】:

  • 我认为代码示例是有序的,例如对于UInteger
  • 包括一个适用于最高有效位的示例。
【解决方案2】:

您可以使用<<>> 运算符,并且您必须指定要移位的位数。

myFinal = myInteger << 4   ' Shift LEFT by 4 bits.
myFinal = myInteger >> 4   ' Shift RIGHT by 4 bits.

您也可以将其用作一元运算符...

myFinal <<= 4     ' Shift myFinal LEFT by 4 bits, storing the result in myFinal.
myFinal >>= 4     ' Shift myFinal RIGHT by 4 bits, storing the result in myFinal.

【讨论】:

  • myFinal 是什么类型?未签名还是已签名?多少位? Integer? UInteger?
猜你喜欢
  • 2012-12-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多