04-25-2016 07:06 PM - edited 04-25-2016 07:08 PM
I just figured out, the logical shift and rotate left with carry functions are not compatible with the EV3. 😞 Any other ideas?
Is there any way to put a boolean array straight into a case structure?
04-25-2016 08:10 PM
Does the Power Of 2 primitive work in the EV3?
04-26-2016 12:32 AM
The simplest functions you need for this are Select or case, Add, Multiply and a shift register. You iterate over the array and if the current value is T, you add N to the running total, where N is the current power of 2. If the power of 2 function is available, you can use that on the i terminal. If it's not, you can simply track it yourself with another shift register and multiplying the value in the second SR by 2 in each iteration.
This code is a very literal interpretation of how binary numbers are represented.
04-26-2016 09:08 PM
@crossrulz wrote:Does the Power Of 2 primitive work in the EV3?
Yes it does!
04-26-2016 09:41 PM
tst wrote:
The simplest functions you need for this are Select or case, Add, Multiply and a shift register. You iterate over the array and if the current value is T, you add N to the running total, where N is the current power of 2. If the power of 2 function is available, you can use that on the i terminal. If it's not, you can simply track it yourself with another shift register and multiplying the value in the second SR by 2 in each iteration.
This code is a very literal interpretation of how binary numbers are represented.
I understand what you're saying, and it will work, but could you explain a little more, or maybe show an example?
My understanding: I have an array, it goes into a for loop through a shift register, then into a case structure of true or false. If it is T, then it goes into another for loop and is added to a power of 2 function whose x is connected to the i of the outside for loop. There are some errors I know, but can you show me what I'm doing wrong?
04-26-2016 11:40 PM
I got it to work finally. Thanks to a combination of your answers! Thanks so much for all your help. (I probably still WAY overcomplicated it).
04-27-2016 01:11 AM
@chasemcd1745 wrote:I probably still WAY overcomplicated it.
Not that part, but the rest of it, yes. I didn't examine the code closely, but there are a number of things which jump out even on a cursory look: