我想知道是否有可能获得数字的最低有效位。
示例:
uint intValue = Int32.MaxValue;
uint LSB = intValue & 0x0000FFFF;
来自:
{{3}}
但是我在VB.net中需要它。
我尝试过:
Dim intValue As UInteger = 39101
Dim LSB As UInteger = intValue And &HFFFF
有什么主意吗?
答案 0 :(得分:0)
这应该有助于您可视化正在发生的事情。它显示了各种口罩。在每个止损处查看“位”。
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)