Science Fair Project Encyclopedia
Programming languages have a set of operators that perform arithmetical operations, and others such as Boolean operations on truth values, and string operators manipulating strings of text. Computers are mathematical devices, but compilers and interpreters require a full syntactic theory of all operations in order to parse formulae involving any combinations correctly. In particular they depend on operator precedence rules, on order of operations, that are tacitly assumed in mathematical writing.
Conventionally, the computing usage of "operator" also goes beyond the mathematical usage (for functions). The C programming language, for example also supports operators like &, ++ and sizeof. Operators like sizeof, which are alphanumeric rather than a mathematical symbol or a punctuation character, it is sometimes called a named operator.
In certain programming languages, such as PostScript, the use of the word "operator" has more specific meaning, in that an operator is an executable element in the stack. Because operators here are always written postfix, the need for parentheses is redundant as the way objects are taken from the stack ensures correct evaluation. This is an example of Reverse Polish notation.
In some programming languages an operator may work with more than one kind of data, (such as in Java where the + operator is used both for the addition of numbers and for the concatenation of strings). Such an operator is said to be overloaded. In languages that support operator overloading by the programmer, such as C++, one can define customized uses for operators; in Prolog, one can also define new operators.
Some languages also allow for the operands of an operator to be of different data types, in which case one of them is coerced to the data type of the other, to permit the operation to occur. For example, in Perl 12 + "3.14", causes the text "3.14159" to be coerced to a number and produces the result 15.14.
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details