# Ada Programming/Operators


## Standard operators

Ada allows operator
overloading for all standard
operators and so the following summaries can only describe the suggested
standard operations for each operator. It is quite possible to misuse
any standard operator to perform something unusual.

Each operator is either a keyword
or a delimiter---hence all
operator pages are redirects to the appropriate
keyword or
delimiter.

Operators have arguments which in the RM are called Left and Right for
binary operators, Right for unary operators (indicating the position
with respect to the operator symbol).

The list is sorted from lowest precedence to highest precedence.

### Logical operators

and : and $x \land y$, `<small>`{=html}(also keyword and)`</small>`{=html}\
or : or $x \lor y$, `<small>`{=html}(also keyword or)`</small>`{=html}\
xor : exclusive or $(x \land \bar{y}) \lor (\bar{x} \land y)$, `<small>`{=html}(also keyword xor)`</small>`{=html}

### Relational operators

/= : Not Equal $x \ne y$, `<small>`{=html}(also special character /=)`</small>`{=html}\
= : Equal $x = y$, `<small>`{=html}(also special character =)`</small>`{=html}\
\< : Less than $x<y$, `<small>`{=html}(also special character \<)`</small>`{=html}\
\<= : Less than or equal to ($x \le y$), `<small>`{=html}(also special character \<=)`</small>`{=html}\
\> : Greater than ($x > y$), `<small>`{=html}(also special character \>)`</small>`{=html}\
\>= : Greater than or equal to ($x \ge y$), `<small>`{=html}(also special character \>=)`</small>`{=html}

### Binary adding operators

+ : Add $x + y$, `<small>`{=html}(also special character +)`</small>`{=html}\
- : Subtract $x - y$, `<small>`{=html}(also special character -)`</small>`{=html}\
& : Concatenate , $x$ & $y$, `<small>`{=html}(also special character &)`</small>`{=html}

### Unary adding operators

+ : Plus sign $+x$, `<small>`{=html}(also special character +)`</small>`{=html}\
- : Minus sign $-x$, `<small>`{=html}(also special character -)`</small>`{=html}

### Multiplying operator

\* : Multiply, $x \times y$, `<small>`{=html}(also special character \*)`</small>`{=html}\
/ : Divide $x / y$, `<small>`{=html}(also special character /)`</small>`{=html}\
mod : modulus `<small>`{=html}(also keyword mod)`</small>`{=html}\
rem : remainder `<small>`{=html}(also keyword rem)`</small>`{=html}

### Highest precedence operator

\*\* : Power $x^y$, `<small>`{=html}(also special character \*\*)`</small>`{=html}\
not : logical not $\lnot x$, `<small>`{=html}(also keyword not)`</small>`{=html}\
abs : absolute value `<small>`{=html} $|x|$ (also keyword abs)`</small>`{=html}

## Short-circuit control forms

These are not operators and thus cannot be overloaded.

and then : *e.g.* **`if`**` Y /= 0 `**`and then`**` X/Y > Limit `**`then`**` ...`\
or else : *e.g.* **`if`**` Ptr = `**`null`**` `**`or else`**` Ptr.I = 0 `**`then`**` ...`

## Membership tests

The Membership Tests also cannot be overloaded because they are not
operators.

in : element of, $var \in type$, *e.g.* ` I `` Positive `, `<small>`{=html}(also keyword )`</small>`{=html}\
not in : not element of, $var \notin type$, *e.g.* ` I `` `` Positive `, `<small>`{=html}(also keywords  )`</small>`{=html}

### Range membership test

` Today `` `` Tuesday .. Thursday `\
`   ...`

### Subtype membership test

`Is_Non_Negative := X `` Natural;`

### Class membership test

` `` Object `` Circle'``;`

### Range membership test

` Today `` `` Tuesday .. Thursday `\
`   ...`

### Choice list membership test

Ada 2012 extended the membership tests to include the union
(short-circuit or) of several range or value choices.

` Today `` Monday .. Wednesday | Friday `\
`   ...`

## See also

### Wikibook

-   Ada Programming

### Ada 95 Reference Manual

-   
### Ada 2005 Reference Manual

-   
### Ada Quality and Style Guide

-   
-   
-   
Programming}}\|Operators

es:Programación en
Ada/Operadores

