08-17-2016 09:36 AM
Alright, so I've got two binary arrays. I believe one is for 20 and the other for 2. So one is 0000010100, and the other is 0000000010. These are displayed in two seperate arrays. Now I want to combine these arrays so that it comes out to:
0000010110. First I wanted to use Insert Into Array Function, which would create a third array and insert both 1's of the first arrays into the third array. But can I also do this by just adding the binary bytes together and then making an array of that? Anyway, I have code attached. It doesn't work but was wondering if yall could take a look.
08-17-2016 09:39 AM - edited 08-17-2016 09:41 AM
Hi Orta,
why don't you OR those "arrays"? The OR is considered a "boolean add"…
As I don't have LV2015 available right now I cannot check your VI and can only guess what you are talking about. But still the OR operation is polymorph and can handle scalar booleans, boolean arrays and also integer (scalar and array)!
08-17-2016 10:54 AM - edited 08-17-2016 10:56 AM
Yes, you can operate directly or the original numbers using boolean operations, no arrays needed.
However, your VI is full of race conditions because of the blatant overuse of local variables. The outcome is not predictable. Also make sure that controls have reasonable default values. Your "input array" is empty and no replacing can ever change that fact.
08-17-2016 11:47 AM
Something like this?
08-17-2016 12:20 PM - edited 08-17-2016 12:45 PM
As I said, you don't need arrays.
(Numeric display is set to %016b. You might also want to mask to 13 bits using AND, etc. so modify as needed. Make sure to use a reasonable datatype)
08-17-2016 12:29 PM
Hey Altenbach, thanks for replying. But if I OR the two binaries together, would that always give the same outcome as if I inserted all the 1's from each array into a final array? But again, thanks. I'll take a look at this.
08-17-2016 12:30 PM - edited 08-17-2016 12:31 PM
@ShogunOrta wrote:Hey Altenbach, thanks for replying. But if I OR the two binaries together, would that always give the same outcome as if I inserted all the 1's from each array into a final array? But again, thanks. I'll take a look at this.
Yes. Logical operations on integers are performed bitwise.
08-17-2016 12:40 PM
@RTSLVU wrote:Something like this?
Only backwards?
Arrays goof with us becuase the LSB is on the left.
Ben
08-17-2016 12:44 PM
You can use a "mask" to select which bits come from where.
In your original post you indicated the low two bits of one of the inputs determine the state of the low two bits of the result.
If you AND the value for the low two bits with a "3" it will mask off the higher order bits.
Do the same with the High order bits with the right maks.
Then OR those two intermediate results for your final answer.
Ben
08-17-2016 02:46 PM
Just to confirm, yep, that worked fine, altenbach.