我想知道是否有可能获得一个数字的最低有效位。
示例:
uint intValue = Int32.MaxValue;
uint LSB = intValue & 0x0000FFFF;
来自:
https://www.oreilly.com/library/view/c-cookbook/0596003390/ch01s06.html
但我需要在VB.net中使用它。
我试过了 :
Dim intValue As UInteger = 39101
Dim LSB As UInteger = intValue And &HFFFF
任何的想法?
这应该可以帮助您可视化正在发生的事情。它显示了各种面具。看看每个站点的'位'。
Dim bits As String
Dim intValue As UInteger = 39101
Dim LSB As UInteger
bits = Convert.ToString(intValue, 2).PadLeft(32, "0"c)
Stop
LSB = intValue And &HFFFFUI 'keep 16 bits
bits = Convert.ToString(LSB, 2).PadLeft(32, "0"c)
Stop
LSB = intValue And &HFFUI 'keep 8 bits
bits = Convert.ToString(LSB, 2).PadLeft(32, "0"c)
Stop
LSB = intValue And &HFUI 'keep 4 bits
bits = Convert.ToString(LSB, 2).PadLeft(32, "0"c)