In logic, mathematics, and computer science, arity (/ˈærɪti/ ⓘ) is the number of arguments or operands taken by a function, operation or relation.
In mathematics, arity may also be called rank,[1][2] but this word can have many other meanings.
In logic and philosophy, arity may also be called adicity and degree.
[5] In general, functions or operators with a given arity follow the naming conventions of n-based numeral systems, such as binary and hexadecimal.
Such functions may have some hidden input, such as global variables or the whole state of the system (time, free memory, etc.).
Examples of unary operators in mathematics and in programming include the unary minus and plus, the increment and decrement operators in C-style languages (not in logical languages), and the successor, factorial, reciprocal, floor, ceiling, fractional part, sign, absolute value, square root (the principal square root), complex conjugate (unary of "one" complex number, that however has two parts at a lower level of abstraction), and norm functions in mathematics.
According to Quine, the Latin distributives being singuli, bini, terni, and so forth, the term "singulary" is the correct adjective, rather than "unary".
Most operators encountered in programming and mathematics are of the binary form.
Logical predicates such as OR, XOR, AND, IMP are typically used as binary operators with two distinct operands.
In CISC architectures, it is common to have two source operands (and store result in one of them).
The computer programming language C and its various descendants (including C++, C#, Java, Julia, Perl, and others) provide the ternary conditional operator ?
The Unix dc calculator has several ternary operators, such as |, which will pop three values from the stack and efficiently compute
Many (RISC) assembly language instructions are ternary (as opposed to only two operands specified in CISC); or higher, such as MOV %AX, (%BX, %CX), which will load (MOV) into register AX the contents of a calculated memory location that is the sum (parenthesis) of the registers BX and CX.
The arithmetic mean of n real numbers is an n-ary function:
Similarly, the geometric mean of n positive real numbers is an n-ary function:
In computer science, a function that accepts a variable number of arguments is called variadic.
For example, 1-ary is based on cardinal unus, rather than from distributive singulī that would result in singulary.
The arity of a relation (or predicate) is the dimension of the domain in the corresponding Cartesian product.