How to cycle through the 16 bits from a UInt16 value

I have a UInt16 value and i need to cycle through each of the bit value like find bit0, bit1 … bit15. Can some one help

Cycle through the bits and do what though?

I am getting the hex value from a serial device. I am reading that value to a memoryblock. All is working fine now i have the required value in n = mb.UInt16(5). Now from n i need to get the bitwise values. There should be 16 bit values. How do i read each bit values from n

You could maybe use the Bitwise module or perform a Bowie’s AND using a decimal number.

Have you checked the new Binary Enumerations? Sounds like a suitable task for one.

Make a loop.
BitwiseAnd to get a bit and bitwise shift to move to next one.