03-23-2010 02:11 AM
Hi,
I want to produce an mirror value of an 8 bit numeric. suppose my value is 11101100, my output should be 00110111. how can i get this??
Solved! Go to Solution.
03-23-2010 02:20 AM
Here is a solution.
03-23-2010 02:21 AM
03-23-2010 02:24 AM
I'd solve it through a small for-loop, bitshift the incoming in one direction (e.g. left) through a shift register and build an outvalue by shifting in values (the output from the former shift) in the other direction (e.g. right).
/Y
03-23-2010 02:30 AM
Sanad MM a écrit:
Use Numeric->Data Manipulation -> Rotate
No, this will not produce the expected mirror !
03-23-2010 06:53 AM - edited 03-23-2010 06:54 AM
My vi works. It has minor changes to the one posted above.
They're explained in the front panel.
//edit: version for LV8.6 added
03-23-2010 10:38 PM
03-24-2010 02:19 AM - edited 03-24-2010 02:19 AM
What we've learned from the bit twiddling challenge, doing the detour over the boolean array is not very efficient. If this is used on huge amounts of data in tight loops, it might be better to use a lookup table instead. Look ma, no green!!! 🙂
(Of course you would create the lookup table once using a FOR loop with N=256, and containing the above code.)
03-24-2010 03:58 AM
I still find my little loop suggestion fun. 😉
/Y
03-24-2010 10:26 AM
Yamaeda wrote:I still find my little loop suggestion fun. 😉
Very cute. That's probably the fastest you can do with explicit code.
Here are some benchmarks (5M U8 numbers, LabVIEW 8.0, debugging disabled).
Green (reverse boolean array): 385ms 10x slower
Yamaeda: 272ms 7x slower
My Lookup table: 39ms winner.
Clearly, the LUT wins hands down. 😉