【发布时间】:2010-11-27 21:46:37
【问题描述】:
如何在 VB.NET 中按位右移/左移?它甚至有operators,还是我必须使用一些实用方法?
【问题讨论】:
-
没错there mate,就在您发布的链接的列表中!
标签: vb.net operators bit-manipulation bit-shift
如何在 VB.NET 中按位右移/左移?它甚至有operators,还是我必须使用一些实用方法?
【问题讨论】:
标签: vb.net operators bit-manipulation bit-shift
您可以使用<< 和>> 运算符,并且您必须指定要移位的位数。
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?