Logical NOR - how to achieve, best practice

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times

Logical NOR - how to achieve, best practice

Post by Jay Dee »

Hi guys,
Previously Jonny has suggested avoiding using too many Logical Operators as they could potentially cause lots of branches and unpredictable behavior during compiling.
What is a good practice method of returning 1, when both source variables are 0?

Although the variables will be whole bytes, only the first bit is ever used...so can I get away with bitwise?
Output = Input1 NOR Input2 ??
Output = Not ( Input1 OR input2)
thanks, J.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Logical NOR - how to achieve, best practice

Post by Benj »

Hello,

What about this?

(!(input1 | input2)) & 0x01

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times

Re: Logical NOR - how to achieve, best practice

Post by Jay Dee »

Thanks Ben,
I'll use that for now, I thought Logical operators were best avoided or is that not always the case? As i see your example uses 3 different types. :)
J.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Logical NOR - how to achieve, best practice

Post by Benj »

Hello,

Jonny may know bettet but I think as long as it is bracketed correctly then it shouldn't be an issue.

This should also work.

(~(input1 | input2)) & 0x01

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times

Re: Logical NOR - how to achieve, best practice

Post by Jay Dee »

Thanks for the clarification Ben.
Good stuff. :)
Coming from a non-cody back ground, its always tricky working out whats ugly but works VS a neat little program!

Post Reply