# DiGrande.it

Blind, Braille and Embossing Technologies

This site uses cookies to personalize content and ads, provide social media features and analyze links. By closing this banner or continuing to browse, you consent to their use.

# Logical operators

There are three logical operators that result in a true or false condition. These are the logical operators:

- & - AND Operator, logical conjunction.

A & B - True if A and B are true, false otherwise.

- | - OR Operator, Logical Disjunction.

A | B - False if A and B are false, true otherwise.

- ! - NOT Operator, logical negation.

! A - True if A is false, false if A is true.

THE LOGICAL CONJUNCTION: AND

The & operator (Commercial E) performs a logical conjunction (AND), resulting in TRUE if both operands are valid TRUE, FALSE otherwise. Since he is a binary operator and each operand has two values, there are four possible combinations.

TRUE & TRUE = TRUE;

FALSE & FALSE = FALSE

FALSE & TRUE = FALSE

TRUE & FALSE = FALSE

The operator implicit in the instructions is always the AND operator. This means that if the logical operator is omitted, it is implicit that it will always be AND. This means that writing "A & B" is the same as writing "A B".

LOGICAL DISCONNECTION: OR

The operator | (Vertical bar) performs a logical separation (OR), resulting in TRUE if one of the operands is TRUE, FALSE if both operands are FALSE. Since he is a binary operator and each operand has two values, there are four possible combinations.

TRUE & TRUE = TRUE;

FALSE & FALSE = FALSE

FALSE & TRUE = TRUE

TRUE & FALSE = TRUE

LOGICAL NEGATION: NOT

The operator ! (exclamation) is used to execute logical negation (NOT). The logical negation of a Boolean value results in the opposite value. If an instruction returns to a true value, then "! Instruction" returns FALSE value, and vice versa. Since logical negation is a single operator, there are only two possible values for its single operator: TRUE or FALSE.

Examples:

A & !B - It is a true condition only if A is TRUE and B is FALSE. It can also be written as: A !B - If instruction A is TRUE and (AND) the denial of instruction B is TRUE, the condition is TRUE, otherwise FALSE.

A | !B - The condition is TRUE if A is TRUE or B is FALSE (logical negation), otherwise it is FALSE.

! A - is a TRUE condition only if A is FALSE.

! A ! B - The condition is only true if A and B are FALSE, since we have used logical negation in both.

! (A B) - Same as above, but using parentheses to group instruction blocks