LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I retrieve the nth bit out of a word?

I'm using Labview 6i.
0 Kudos
Message 1 of 3
(3,013 Views)
Well, to get n, there has to be an array. So, convert the word to an array, I would suggest splitting it into two bytes, then converting to boolean arrays, then concatenating the arrays. Then, just index your array, and reconvert back to 0/1.

Good luck
0 Kudos
Message 2 of 3
(3,013 Views)
You could also make a single AND operation. This does not only work with booleans but also with integer numbers.
Let's assume that:
X = word to analyze
Y = value for AND operation
Z = result of X AND Y

If Z = 0: nth bit of X = False
If Z > 0: nth bit of X = True

The value for Y is 2^n (power)
For example
n Y
0 1
1 2
2 4
...
15 32768

The best is to switch the representation of Y to binary. So you can easily set the only bit you are interested in to 1.
0 Kudos
Message 3 of 3
(3,013 Views)