In mathematics and computer programming the arity of a function or an operator is the number of arguments or operands it takes (arity is sometimes referred to as valency, although that actually refers to another meaning of valency in mathematics). The naming follows the same convention as the naming used for n-based number systems (compare binary and hexadecimal). In these cases, it is the Latin prefix and the -ary ending that creates each arity. Below is a list of some examples.
The arity of a function or operator of:
- nullary or anary means zero parameters.
- unary means one parameter.
- binary means two parameters.
- ternary, also trinary and tertiary, means three parameters.
- quaternary means four parameters.
- quinary means five parameters.
- senary means six parameters.
- septenary means seven parameters.
- octonary means eight parameters.
- nonary means nine parameters.
- denary means ten parameters.
- undenary means eleven parameters.
- duodenary means twelve parameters.
- vigesary means twenty parameters.
- centenary means a hundred parameters.
- millenary means a thousand parameters.
- n-ary means n parameters
Note however, that anything above quinary is hardly found in any math- or programming-related literature. It is however often used to describe anything related to that number (i.e. undenary chess is a chess variant with an 11x11 board, or Millenary Petition of 1603).
Table of contents
Sometimes, it is useful to consider a constant as an operator or function of arity 0, and hence call it nullary (or sometimes anary).
Examples of unary operators in math and in programming include the unary minus and plus, the add-one or subtract-one operator in C-style languages, not in logical languages and the factorial function in math. Also, the two's complement operator and the address reference operators are examples of unary operators in math and programming.
Most operators encountered in programming are of the binary form. For both programming and math these can be the multiplication operator, the addition operator, the division operator. Logical predicates such as OR, XOR, AND, IMP are typically used as binary operators with two distinct operands.