Boolean operations on strings

User: "Jeff_wu"
Altair Community Member
Updated by Jeff_wu

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.

Find more posts tagged with

Sort by:
1 - 2 of 21
    User: "pdarnell"
    Altair Employee
    Updated by pdarnell

    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:

    image

    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:

    image

    User: "Jeff_wu"
    Altair Community Member
    OP
    Updated by Jeff_wu

    Can I perform bitwise operations directly on a string? For example, whether the received string is equal to "Hello", it may receive more than two different strings.