# Boolean - (Logical) Operator (OR, AND, XOR, ...)

> (Data|State|Operand) Management and Processing > (Data Type|Data Structure) > Data Type - Boolean

### Table of Contents

## 1 - About

Boolean operator manipultes `truthy`

and `falsy`

values that can come from:

- a Boolean value
- the interpretation of a non-boolean value (ie javascript (truthy/falsy))
- or the result of a comparison expression.

Boolean operator has the same than arithmetic bitewise operator

## 2 - Articles Related

## 3 - Syntax

General syntax is

lhs operator rhs

where:

`lhs`

stands for left-hand side operand`operator`

a boolean/logical operator`rhs`

stands for right-hand side operand

### 3.1 - Negation

Any Boolean expression (such as the outcome of a comparison operator may be negated with not.

Syntax example:

not(expression) # or !(expression)

### 3.2 - Operator

Operator | Description | Logic |
---|---|---|

`&&` | Logical AND | If `rhs` is falsy, the expression evaluates to `lhs` |

`||` | Logical OR | if `lhs` is truthy, the expression evaluates to `lhs` , otherwise, it evaluates to `rhs` |

`&` | Bitwise AND | |

`|` | Bitwise OR | |

`^` | Bitwise exclusive OR |

`&&`

and `||`

exhibit short-circuiting“ behavior, which means that the second operand is evaluated only if needed

## 4 - Computer

In computer, a logical operator is implemented by a logic gate

## 5 - Order of precedence

Grammar - (Order of (operations|precedence)|operator precedence)

And and OR have normally lower priorities than comparison operators

Between them, not has the highest priority and or the lowest, so that:

A and not B or C

is equivalent to

(A and (not B)) or C.