Working with binaries
fzrobot
Posts: 7
Ok, so who else thinks this is weird?
Let's say I have a signed binary number coming from a device into the stamp via
then I subtract them (as an example take my values: axisCount=0000100111001111 VRefCount = 0000011111111110)
And for the sake's of the argument let's assume that axisCount is ALWAYS greater than VrefCount.
Then, this is my "problem":
If I do the conditional:
it evaluates to a true statement for the numbers I presented above (and thus, it prints "The conditional is true").
However, if I (without changing or touching anything on the Boe-Bot) do this "minor" change
then all of the sudden it evaluates to a false statement (it doesn't print the line)
Anybody finds this weird?
Thanks,
-Cisco
Let's say I have a signed binary number coming from a device into the stamp via
SHIFTIN Dio, Clk, MSBPOST, [noparse][[/noparse]VRefCount\13] ... SHIFTIN Dio, Clk, MSBPOST, [noparse][[/noparse]axisCount\13]
then I subtract them (as an example take my values: axisCount=0000100111001111 VRefCount = 0000011111111110)
subtraction = axisCount - VrefCount
And for the sake's of the argument let's assume that axisCount is ALWAYS greater than VrefCount.
Then, this is my "problem":
If I do the conditional:
IF (subtraction>800) THEN DEBUG "The conditional is true" GOTO Main ENDIF
it evaluates to a true statement for the numbers I presented above (and thus, it prints "The conditional is true").
However, if I (without changing or touching anything on the Boe-Bot) do this "minor" change
IF ((subtraction>800)|(subtraction<300) THEN DEBUG "The conditional is true" GOTO Main ENDIF
then all of the sudden it evaluates to a false statement (it doesn't print the line)
Anybody finds this weird?
Thanks,
-Cisco
Comments
It appears you want to use a LOGICAL AND and not a BITWISE AND. The former is a LOGICAL operation and the latter is an ARITHMETIC operation. Make the following change:
From -
IF ((subtraction>800)|(subtraction<300) THEN
To:
IF ((subtraction>800) and (subtraction<300) THEN
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Thanks, btw, | is bitwise OR, so I just changed it for the "OR" binary operator to do what I intended.
Thanks again.
Cheers,
-Cisco