## Operators

## Reference.Operators History

Show minor edits - Show changes to output

Added lines 1-75:

'''Operator Precedence'''

|| border=1 style="border-collapse:collapse" cellpadding=3 width=40% bgcolor=#f4f4f4

||!Level ||!Operators||

||1||unary -, unary +||

||2||*, /||

||3||MOD||

||4||+, -||

||5||&||

||6||<<, >>||

||7||=, <, >, <=, >=, <>||

||8||NOT||

||9||AND, ANDALSO||

||10||OR, ORELSE||

||11||XOR||

Operators at level one have the highest precedence, with operators at level seven having the lowest precedence. Parentheses can be used to override the order of precedence rules, allowing parts of an expression to be evaluated before others.

'''Relational Operators'''

The operators used for comparison are called relational operators. Applying a relational operator will yield a result of true or false.

|| border=1 style="border-collapse:collapse" cellpadding=3 width=40% bgcolor=#f4f4f4

||Operator ||Meaning||

||= ||Is equal to||

||< ||Is less than||

||> ||Is greater than||

||<= ||Is less than or equal to||

||>= ||Is greater than or equal to||

||<> ||Is not equal to||

The only relational operators supported for string types are equal and not equal, unless the string is being compared against nothing., in which case "is" and "isnot" may be used. Because the internal binary representation of floating point numbers may not be exact, the equality operator should be avoided for floating point numbers.

'''Mathematical Operators'''

|| border=1 style="border-collapse:collapse" cellpadding=3 width=40% bgcolor=#f4f4f4

||Operator ||Meaning||

||* ||Multiply||

||/ ||Divide||

||+ ||Addition||

||- ||Subtraction||

||MOD ||Modulus||

In addition to the mathematical operators shown above, you can use the unary operator to change the sign. For example,

=firewing [=

Sub Main()

Dim Value As SByte

Value = 10 ' Value = 10

Value = -Value ' Value = -10

End Sub

=]

'''Logical Operators'''

|| border=1 style="border-collapse:collapse" cellpadding=3 width=40% bgcolor=#f4f4f4

||Operator ||Meaning||

||NOT ||Negate||

||AND ||Logical AND||

||OR ||Logical OR||

||XOR ||Logical XOR||

Logical operators can be used to build conditional expressions, for example, when using if…then, while…end while and do…repeat until statements. Applying a boolean operator yields either true or false.

'''Bitwise Operators'''

The following operators perform bitwise manipulation on integer operands.

|| border=1 style="border-collapse:collapse" cellpadding=3 width=40% bgcolor=#f4f4f4

||Operator ||Meaning||

||NOT ||A bitwise NOT or complement||

||AND ||Bitwise AND||

||OR ||Bitwise OR||

||XOR ||Bitwise XOR||

||<< ||Shift Left||

||>> ||Shift Right||

|| border=1 style="border-collapse:collapse" cellpadding=3 width=40% bgcolor=#f4f4f4

||!Level ||!Operators||

||1||unary -, unary +||

||2||*, /||

||3||MOD||

||4||+, -||

||5||&||

||6||<<, >>||

||7||=, <, >, <=, >=, <>||

||8||NOT||

||9||AND, ANDALSO||

||10||OR, ORELSE||

||11||XOR||

Operators at level one have the highest precedence, with operators at level seven having the lowest precedence. Parentheses can be used to override the order of precedence rules, allowing parts of an expression to be evaluated before others.

'''Relational Operators'''

The operators used for comparison are called relational operators. Applying a relational operator will yield a result of true or false.

|| border=1 style="border-collapse:collapse" cellpadding=3 width=40% bgcolor=#f4f4f4

||Operator ||Meaning||

||= ||Is equal to||

||< ||Is less than||

||> ||Is greater than||

||<= ||Is less than or equal to||

||>= ||Is greater than or equal to||

||<> ||Is not equal to||

The only relational operators supported for string types are equal and not equal, unless the string is being compared against nothing., in which case "is" and "isnot" may be used. Because the internal binary representation of floating point numbers may not be exact, the equality operator should be avoided for floating point numbers.

'''Mathematical Operators'''

|| border=1 style="border-collapse:collapse" cellpadding=3 width=40% bgcolor=#f4f4f4

||Operator ||Meaning||

||* ||Multiply||

||/ ||Divide||

||+ ||Addition||

||- ||Subtraction||

||MOD ||Modulus||

In addition to the mathematical operators shown above, you can use the unary operator to change the sign. For example,

=firewing [=

Sub Main()

Dim Value As SByte

Value = 10 ' Value = 10

Value = -Value ' Value = -10

End Sub

=]

'''Logical Operators'''

|| border=1 style="border-collapse:collapse" cellpadding=3 width=40% bgcolor=#f4f4f4

||Operator ||Meaning||

||NOT ||Negate||

||AND ||Logical AND||

||OR ||Logical OR||

||XOR ||Logical XOR||

Logical operators can be used to build conditional expressions, for example, when using if…then, while…end while and do…repeat until statements. Applying a boolean operator yields either true or false.

'''Bitwise Operators'''

The following operators perform bitwise manipulation on integer operands.

|| border=1 style="border-collapse:collapse" cellpadding=3 width=40% bgcolor=#f4f4f4

||Operator ||Meaning||

||NOT ||A bitwise NOT or complement||

||AND ||Bitwise AND||

||OR ||Bitwise OR||

||XOR ||Bitwise XOR||

||<< ||Shift Left||

||>> ||Shift Right||