Support Forums
Find bit status of a number

Hi community. I am trying to use a calculation tag to determine the bit status of an analog value. I cannot seem to get the syntax correct to put in the expression. I found the code snippet below but I think that may be for scripting not expressions...not sure Is there any documentation on functions and syntax for these expressions? trying [value] && 4 does not work to find the status of the 3rd bit. I cant seem to find any using F1 help. Thank you

5dfd7df070c36

Hi community. I am trying to use a calculation tag to determine the bit status of an analog value. I cannot seem to get the syntax correct to put in the expression. I found the code snippet below but I think that may be for scripting not expressions...not sure Is there any documentation on functions and syntax for these expressions? trying [value] && 4 does not work to find the status of the 3rd bit. I cant seem to find any using F1 help. Thank you ![5dfd7df070c36](serve/attachment&path=5dfd7df070c36)

Hi Michael, not sure why your reply is not showing on the forum but the code you provided does not seem to work. This expression just toggles 0-1 depending if the number is even or odd. what I am looking for is to find the status of a bit in a number such as 512, the 10th bit is "high" and I want to react based off that state, thank you.

Is there any documentation on how to write expressions? Thank you

"Hi,

Michael has replied to the topic: Find bit status of a number


[Value] % 2^x == 0 where x is the bit number."

Hi Michael, not sure why your reply is not showing on the forum but the code you provided does not seem to work. This expression just toggles 0-1 depending if the number is even or odd. what I am looking for is to find the status of a bit in a number such as 512, the 10th bit is "high" and I want to react based off that state, thank you. **Is there any documentation on how to write expressions?** Thank you "Hi, Michael has replied to the topic: Find bit status of a number ---- [Value] % 2^x == 0 where x is the bit number." ----
72
1
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft