I wonder if it's possible to obtain the Least-significant bits of a number.
Example :
uint intValue = Int32.MaxValue;
uint LSB = intValue & 0x0000FFFF;
from :
https://www.oreilly.com/library/view/c-cookbook/0596003390/ch01s06.html
but I need this in VB.net.
I tried :
Dim intValue As UInteger = 39101
Dim LSB As UInteger = intValue And &HFFFF
Any idea?
This should help you visualize what is going on. It shows various masks. Look at 'bits' at every Stop.
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)
User contributions licensed under CC BY-SA 3.0