# Operator

*407*pages on

this wiki

**Operators** in programming are analogous to mathematical *operators*. Operators take in one or more operands and returns a value. Most programming languages only support unary and binary operators. Others such as C have greater arity operators such as the ternary operator `?:`

.

## Operator overloading Edit

If operators can be defined in a programming language, the programmer may define custom uses for a specific operation. This is called operator overloading.

Only a specific set of operators can be overloaded.

## Precedence Edit

Operatos also follow a certain precedence in evaluation. For example, multiplication and division always come before addition and subtraction. Mathematical operations go before relational operators.

## Common operators Edit

This lists common operators found in most programming languages and the most common symbol(s) associated with them. Symbols may vary or may not be available depending on the language.

- Unary mathematical operators

- positive/identity:
`+`

- negative:
`-`

- Binary mathematical operators

- addition:
`+`

- subtraction:
`-`

- multiplication:
`*`

- division:
`/`

- modulus / remainder:
`%`

- exponentiation:
`**`

,`^`

- Relational and equality operators (binary)

- equality:
`=`

,`==`

- inequality:
`!=`

,`<>`

- less than:
`<`

- greater than:
`>`

- less than or equal to:
`<=`

- greater than or equal to:
`>=`

- String operators

- concatenation:
`+`

,`&`

- Logical operators

- logical AND:
`&`

- logical OR:
`|`

- logical exclusion
- logical negation:
`!`

- bitwise AND:
`&`

- bitwise OR:
`|`

- bitwise negation:
`~`

- short-circuit logical AND:
`&&`

- short-circuit logical OR:
`||`

- ternary conditional:
`?:`

see also Boolean

- Bit shift operators

- arithmetic left shift:
`<<`

- arithmetic right shift:
`>>`

- Incrementing operators

This type of operators may either be prefix (placed before the operand) or postfix (placed after the operand). Prefix operations are evaluated before the main evaluation of the program line, while postfix operations are evaluated after the main evaluation of the program line.

- increment:
`++`

- decrement:
`--`

- Assignment operators

- assignment:
`=`

- compound assignment: X
`=`

, where X is an operator

- Type and reference operators

- type checking (x is of type T):
`is`

- type retrieval (returns the type of x):
`typeof(x)`

- type conversion
- reference equality
- method reference

- Pointer operators

(low-level languages)

- variable address:
`&`

- indirection:
`*`

- struct member access:
`->`