m Date/fix the maintenance tags or gen fixes |
remove "C does not include [in]equality as a set of relational operators" -- my S. Prata book of C says these are "Relational operators" |
||
Line 1: | Line 1: | ||
{{Mergefrom|eqeq|date=July 2007}} |
{{Mergefrom|eqeq|date=July 2007}} |
||
In [[computer science]] a '''relational operator''' is a [[programming language]] construct that tests some kind of [[relation (mathematics)|relation]] between two entities, for example, ''[[equality (mathematics)|equality]]'' or ''[[greater than]]''. These operators usually return true or false, depending on whether the relationship between the two [[operands]] holds or not. |
In [[computer science]] a '''relational operator''' is a [[programming language]] construct that tests some kind of [[relation (mathematics)|relation]] between two entities, for example, ''[[equality (mathematics)|equality]]'' or ''[[greater than]]''. These operators usually return true or false, depending on whether the relationship between the two [[operands]] holds or not. An [[expression (programming)|expression]] created using a relational operator forms what is known as a ''relational expression'' or a ''condition''. |
||
In some languages (e.g., [[C (programming language)|C]]) the set of relational operators does not include equality and inequality, which are classified as being ''equality operators''. An [[expression (programming)|expression]] created using a relational operator forms what is known as a ''relational expression'' or a ''condition''. |
|||
Relational operators are usually written in [[infix]] notation, if supported by the programming language, which means that they appear between their operands (the two expressions being related). However, some programming languages, such as [[Lisp programming language|Lisp]], use [[Prefix notation|prefix]] notation, as follows: |
Relational operators are usually written in [[infix]] notation, if supported by the programming language, which means that they appear between their operands (the two expressions being related). However, some programming languages, such as [[Lisp programming language|Lisp]], use [[Prefix notation|prefix]] notation, as follows: |
Revision as of 02:05, 19 July 2007
In computer science a relational operator is a programming language construct that tests some kind of relation between two entities, for example, equality or greater than. These operators usually return true or false, depending on whether the relationship between the two operands holds or not. An expression created using a relational operator forms what is known as a relational expression or a condition.
Relational operators are usually written in infix notation, if supported by the programming language, which means that they appear between their operands (the two expressions being related). However, some programming languages, such as Lisp, use prefix notation, as follows:
(>= X Y)
Here are some of the most common relational operators in use in programming languages:
Relational Operator | Meaning |
---|---|
== |
Equality or identity. Used to test the equivalence of two expressions or the identity of two objects. |
=== |
Variant of identity. In some languages (e.g. PHP), represents a stronger sense of equality than == . In PHP, the result of $a === $b is TRUE if $a is equal to $b , and they are of the same type[1].
|
= |
Variant of equality. (Also an assignment operator in C-like languages.) |
<> |
Inequality. (Also a file-search specifier 'operator' in Perl.) |
!= |
Variant of inequality. Used to test the equivalence of two expressions. |
/= |
Variant of inequality. This is not as common as the above operator. |
^= |
Variant of inequality. This is not as common as the above operator. (Also a bitwise XOR assignment in C-like languages.) |
> |
Greater than. Used to test if the value of the left expression is greater than that of the right expression. |
< |
Less than. Used to test if the value of the left expression is less than that of the right expression. |
>= |
Greater than or equal to. Used to test if the value of the left expression is greater than or equal to that of the right expression. |
<= |
Less than or equal to. Used to test if the value of the left expression is less than or equal to that of the right expression. |
=< |
Variant of less than or equal to. |
!> |
Not greater than. Used in SQL. |
!< |
Not less than. Used in SQL. |
Uses outside of programming
Relational operators are sometimes used in communities of technical nature instead of words.