Logical Operations

Read(2087) 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.

Parameter:

x

An expression

y

An expression

Return value:

Boolean

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