LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos
clendon.gibson@canrig.com

don't just discard the bit from a logical shift

Status: Declined

Any idea that has not received any kudos within a year after posting will be automatically declined.

Logical shift in LabVIEW discards the shifted out bit. Logical shift functions in assembly labguage settings shift that value to an overflow bit register allowing the bit in question to be tested and program flow to be altered.

 

This kind of function is useful when dealing with low level protocols at the bit level, or dealing with digital devices that have a parallel interface.

 

I suggest the logical shift function have an additional output that contains the boolean value of the bit just shifted out of the number.

 

Logical shift should be able to output a single boolean, or an array of boolean. For the single case, the value would be the last bit shifted out with other bits being lost. For the array output, all bits would be captured with the first bit shifted out being the 0th index of the array.

5 Comments
altenbach
Knight of NI

Why don't you use "rotate left/right with carry" instead?

clendon.gibson@canrig.com
Member

Your right. The rotate right and left with carry do almost everything I want. They don't rotate n bits, and they don't give you an array output option, but these are things that can be coded easily enough.

 

 

RavensFan
Knight of NI

What if you shifted the number one way by n bits, and also the same number the other way by X-n bits (where X is the bit size of the datatype).  One number will have the shifted value, the other will have the discarded bits.

clendon.gibson@canrig.com
Member

This is another good suggestion.

 

The only thing I would have to watch out for is which bit got shifted out first. This can be calculated but you have to take into account left shift versus right shift.

Darren
Proven Zealot
Status changed to: Declined

Any idea that has not received any kudos within a year after posting will be automatically declined.