| This article does not cite any references or sources. Please help improve this article by adding citations to reliable sources. Unverifiable material may be challenged and removed. (November 2008) |
| This article may require cleanup to meet Wikipedia's quality standards. Please improve this article if you can. (November 2008) |
An operand is one of the inputs (arguments) of an operator in mathematics. The following arithmetic expression shows an example of operators and operands:
- 3 + 6 = 9
Here '+' is the operator and '3' and '6' are the operands.
Contents |
[edit] Notation
[edit] Expressions as operands
Operands may be complex, and may consist of expressions also made up of operators with operands.
- (3 + 5) x 2
In the above expression '(3 + 5)' is the first operand for the multiplication operator and '2' the second. The operand '(3 + 5)' is an expression in itself, which contains an addition operator, with the operands '3' and '5'.
[edit] Order of operations
Rules of precedence affect which values form operands for which operators: j
- 3 + 5 x 2
In the above expression, the multiplication operator has the higher precedence than the addition operator, so the multiplication operator has operands of '5' and '2'. The addition operator has operands of '3' and '5 x 2'.
[edit] Positioning of operands
Depending on the mathematical notation being used the position of an operator in relation to its operand(s) may vary. In everyday usage infix notation is the most common, however other notations also exist, such as the prefix and postfix notations. These alternate notations are most common within computer science.
Below is a comparison of three different notations — all represent an addition of the numbers '1' and '2'
- 1 + 2 (infix notation)
- + 1 2 (prefix notation)
- 1 2 + (postfix notation)
[edit] Arity
The number of operands of an operator is called its arity. Based on arity, operators are classified as nullary (no operands), unary (1 operand), binary (2 operands), ternary (3 operands) etc.
[edit] Computer science
In computer programming languages, the definitions of operator and operand are almost the same as in mathematics.
Additionally, in assembly language, an operand is a value (an argument) on which the instruction, named by mnemonic, operates. The operand may be a processor register, a memory address, a literal constant, or a label. A simple example (in the PC architecture) is
- MOV DS, AX
where the value in register operand 'AX' is to be moved into register 'DS'. Depending on the instruction, there may be zero, one, two, or more operands.