05-12-2020 02:54 PM
I have the following array of binary bits
What I want to do is take each of the bits for each of the elements and arrange them as an element for example:
as shown below the 1st 8 bits for each of the elements are arranged on array 2 as an element of 8 bits:
0 ---->00000000
0
0
0
0
0
0
0
Solved! Go to Solution.
05-12-2020 03:45 PM - edited 05-12-2020 03:53 PM
I would look at it this way.
Convert the numbers to a boolean array. Do it in a loop to get a 2D array.
Transpose the boolean 2D Array.
Convert each row back to a number withing a loop.
Turns out it also needs to reverse the 1-D boolean arrays before and after the transpose.
I'm sure there are other ways to do this, and some may be more efficient.
But this works.
05-12-2020 03:59 PM
I'd call on my old buddy Type Cast Man
05-12-2020 04:14 PM
That worked! Thanks.
05-12-2020 04:15 PM
This also worked. Thanks.
05-12-2020 04:51 PM - edited 05-12-2020 04:51 PM
Of course real programmers really hate to have green bits, because they use 8x more memory. Here's an all blue solution that works just as well. 😄
(I am sure it can be simplified further;))
05-12-2020 05:52 PM - edited 05-12-2020 06:54 PM
@altenbach wrote:(I am sure it can be simplified further;))
Plenty of alternatives. Here's another version, same result (many repetitive operations can be precalculated):
Note that this old idea could eliminate the inner FOR loop, so please vote for it. 😄