LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

setting a bit within byte?

Can someone quickly explain how to set a particalur bit within a byte? In C I would do it this way. Val|= 1 << x; but I'm little confused with the way the logical shift in Labview works because I can't seem to make it work correctly. Thanks so much!

0 Kudos
Message 1 of 6
(3,242 Views)
Message 2 of 6
(3,232 Views)

The logical functions work on integer data types.  Just OR the desired bit with the previous value of the byte to set the bit True.  To set it False AND with a mask having all other bits True.

 

Lynn

0 Kudos
Message 3 of 6
(3,231 Views)

Thanks guys, can someone give me a quick example using the logical switch method of ORing the bits in. For example, if I need to set bits 6 & 7 to a particular setting, but leave the other data bits in tact how would I do this using the logical shift and OR method in labview?

0 Kudos
Message 4 of 6
(3,221 Views)

Here is a simple example.

 

Lynn

Message 5 of 6
(3,203 Views)

Hi,

 

if you do not need it in some code that performs zilions of operations within a second,

much more programmer friendly is to convert the byte into boolean array (my humble opinion).

 

snippy.png

 

 

Message 6 of 6
(3,179 Views)