Boolean operations on strings
I am using Real Time Serial Read to read serial communication from an Arduino. I want to perform boolean operations on the received string for further processing, but it seems that Embed does not support direct boolean operations on strings. What should I do? Do I need to convert the string to binary first, or is there a faster way? If I need to convert the string to binary, how can I do that? Alternatively, are there any other better ways to perform boolean operations on strings?
Thank you for your response. It will be helpful to me.
You can use Boolean AND,OR,XOR directly with numeric strings. They will be converted to integers, then operated on in a bitwise manner. So this will work fine:
note that while single digit ones and zeros work as you would expect, 0x2 AND 0x1 = 0, since it is a bitwise operator. So 0x3 AND 0x1 =1
If you want to treat your numeric strings as zero vs non zero do this: