Logical Operations

Read(268) Label: oolean expression,

Description:

Perform logical operations on two boolean expressions.

Syntax:

x&&y

Logical AND operation; If both x and y are true, then the result is true. Otherwise, it is false. As long as the left operand value is false, the final result will always be false, no matter the right operand value is true or false.

x||y

Logical OR operation; The result is true as long as either x or y is true. Otherwise, it is false. As long as the left operand value is true, the final result is always the true, no matter the right operand value is true or false.

!x

Logical NOT operation, which gets the reverse value of the original value.

Note:

The operands to logical operators are boolean values. If the operand is not a boolean value, then it will be automatically converted to the boolean one. The result is a boolean value.

Parameters:

x

An expression

y

An expression

Return value:

true/false

Example:

 

A

 

1

=(2>1)&&(3<4)

true

2

=(2>10)&&(3<4)

false

3

=(2>1)||(3<4)

true

4

=(2>10)||(3<4)

true

5

=(2>11)

false

6

=! (2>11)

true

7

=!(12-11)

false