Binary operations: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
(edit)
(edit)
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
A binary operator is an operator which takes 2 arguments, as opposed to a [[Unary operators|unary operators]], which take 1 argument.
A binary operator is an operator which takes 2 arguments, as opposed to a [[Unary operations|unary operations]], which take 1 argument.


Below is the list of binary operators:
Below is the list of binary operators:
<br>
<nowiki>
=
</nowiki>


<br>
{|
<nowiki>
|-valign="top"
:=
|width="10%"|'''Operator'''|| '''Effect'''
</nowiki>
|-valign="top"
 
|width="10%"|'''='''||may be used for assignment or comparing 2 values like the '''==''' operator
<br>
|-valign="top"
<nowiki>
|width="10%"|''':='''||forced assignment
<>
|-valign="top"
</nowiki>
|width="10%"|'''<>'''||not equal
 
|-valign="top"
<br>
|width="10%"|'''&'''||concatenation of strings
<nowiki>
|-valign="top"
&
|width="10%"|'''*'''||multiplication
</nowiki>
|-valign="top"
 
|width="10%"|'''*='''||multiplication of the left operand by the right operand followed by assignment of the result to the left operand
<br>
|-valign="top"
<nowiki>
|width="10%"|'''+'''||addition
*
|-valign="top"
</nowiki>
|width="10%"|'''+='''||addition of the left operand to the right operand followed by assignment of the result to the left operand
 
|-valign="top"
<br>
|width="10%"|'''-'''||subtraction
<nowiki>
|-valign="top"
*=
|width="10%"|'''-='''||subtraction of the right operand from the left operand followed by assignment of the result to the left operand
</nowiki>
|-valign="top"
 
|width="10%"|'''/'''||division
<br>
|-valign="top"
<nowiki>
|width="10%"|'''/='''||division of the left operand by the right operand followed by assignment of the result to the left operand
+
|-valign="top"
</nowiki>
|width="10%"|'''<'''||less than
 
|-valign="top"
<br>
|width="10%"|'''<='''||less than or equal to
<nowiki>
|-valign="top"
+=
|width="10%"|'''=='''||equality
</nowiki>
|-valign="top"
 
|width="10%"|'''>'''||more than
<br>
|-valign="top"
<nowiki>
|width="10%"|'''>='''||more than or equal to
-
|-valign="top"
</nowiki>
|width="10%"|'''and'''||logical AND
 
|-valign="top"
<br>
|width="10%"|'''&&'''||logical AND. The use of AND is preferred for readability.
<nowiki>
|-valign="top"
-=
|width="10%"|'''or'''||logical OR
</nowiki>
|-valign="top"
 
|width="10%"|'''<nowiki>||</nowiki>'''||logical OR. The use of OR is preferred for readability.
<br>
|}
<nowiki>
<noinclude>
/
[[Category:Operations]]
</nowiki>
</noinclude>
 
<br>
<nowiki>
/=
</nowiki>
 
<br>
<nowiki>
<
</nowiki>
 
<br>
<nowiki>
<=
</nowiki>
 
<br>
<nowiki>
==
</nowiki>
 
<br>
<nowiki>
>
</nowiki>
 
<br>
<nowiki>
>=
</nowiki>
 
<br>
<nowiki>
and
</nowiki>
 
<br>
<nowiki>
or
</nowiki>

Latest revision as of 07:29, 11 January 2012

A binary operator is an operator which takes 2 arguments, as opposed to a unary operations, which take 1 argument.

Below is the list of binary operators:

Operator Effect
= may be used for assignment or comparing 2 values like the == operator
:= forced assignment
<> not equal
& concatenation of strings
* multiplication
*= multiplication of the left operand by the right operand followed by assignment of the result to the left operand
+ addition
+= addition of the left operand to the right operand followed by assignment of the result to the left operand
- subtraction
-= subtraction of the right operand from the left operand followed by assignment of the result to the left operand
/ division
/= division of the left operand by the right operand followed by assignment of the result to the left operand
< less than
<= less than or equal to
== equality
> more than
>= more than or equal to
and logical AND
&& logical AND. The use of AND is preferred for readability.
or logical OR
|| logical OR. The use of OR is preferred for readability.