Logical operators

### 5.1.4 Logical operators

Booleans can be combined to form new booleans. For example with and, the statement “bool1 and bool2” is true if both bool1 and bool2 are true, otherwise the statement is false.

Xcas has the standard boolean operators, as follows (a and b are two booleans):

- or or || — These are infixed operators. (a or b) (or (a || b)) returns 0 (or false) if a and b are both equal to 0 (or false) and returns 1 (or true) otherwise.
- xor — This is an infixed operator. It is the “exclusive or” operator, meaning “one or the other but not both”. (a xor b) returns 1 if a is equal to 1 and b is equal to 0 or if a is equal to 0 and b is equal to 1, and returns 0 if a and b are both equal to 0 or if a and b are both equal to 1.
- and or && — These are infixed operators. (a and b) (or (a && b)) returns 1 (or true) if a and b are both equal to 1 (or true) and returns 0 (or false) otherwise.
- not — This is a prefixed operator. not(a) returns 1 (or true) if a is equal to 0 (or false), and 0 (or false) if a is equal to 1 (or true).

#### Examples

1>=0 or 1<0

1 |  |  |  |  |  |  |  |  |  |

1>=0 xor 1>0

0 |  |  |  |  |  |  |  |  |  |

1>=0 and 1>0

1 |  |  |  |  |  |  |  |  |  |

not(0==0)

0 |  |  |  |  |  |  |  |  |  |