Difference between revisions of "Documentation/BASIC Guide/Operators"
From Apache OpenOffice Wiki
< Documentation | BASIC Guide
(15 intermediate revisions by 6 users not shown) | |||
Line 7: | Line 7: | ||
|lang=block | |lang=block | ||
}} | }} | ||
− | + | ||
− | {{ | + | {{AOo}} Basic understands common mathematical, logical, and comparison operators. |
== Mathematical Operators == | == Mathematical Operators == | ||
− | Mathematical operators can be applied to all numbers types, whereas the + operator can also be used to | + | Mathematical operators can be applied to all numbers types, whereas the + operator can also be used to concatenate strings. |
{| | {| | ||
− | |<tt>+</tt>||Addition of numbers and date values, | + | |<tt>+</tt>||Addition of numbers and date values, concatenation of strings |
+ | |- | ||
+ | |<tt>&</tt>||Concatenation of strings | ||
|- | |- | ||
|<tt>-</tt>||Subtraction of numbers and date values | |<tt>-</tt>||Subtraction of numbers and date values | ||
Line 27: | Line 29: | ||
|<tt>^</tt>||Raising the power of numbers | |<tt>^</tt>||Raising the power of numbers | ||
|- | |- | ||
− | |<tt>MOD</tt>|| | + | |<tt>MOD</tt>||modulo operation (calculation of the remainder of a division) |
|} | |} | ||
+ | |||
+ | {{Note|Although you can use the + operator to concatenate strings, the Basic interpreter can become confused when concatenating a number to a string. The & operator is safer when dealing with strings because it assumes that all arguments should be strings, and converts the arguments to strings if they are not strings.}} | ||
== Logical Operators == | == Logical Operators == | ||
− | Logical operators allow you to | + | Logical operators allow you to do operations on elements according to the rules of Boolean algebra. If the operators are applied to Boolean values, the operation provides the result required directly. If used in conjunction with integer and long integer values, the operation is done at the bit level. |
{| | {| | ||
− | |<tt>AND</tt>||And | + | |<tt>AND</tt>||And operator |
|- | |- | ||
− | |<tt>OR</tt>||Or | + | |<tt>OR</tt>||Or operator |
|- | |- | ||
− | |<tt>XOR</tt>||Exclusive | + | |<tt>XOR</tt>||Exclusive Or operator |
|- | |- | ||
|<tt>NOT</tt>||Negation | |<tt>NOT</tt>||Negation | ||
Line 66: | Line 70: | ||
|} | |} | ||
− | {{Documentation/ | + | {{Documentation/VBAnote|{{AOo}} Basic does not support the VBA <tt>Like</tt> comparison operator.}} |
− | + | ||
+ | |||
+ | {{InterWiki Languages BasicGuide|articletitle=Documentation/BASIC Guide/Operators}} | ||
{{PDL1}} | {{PDL1}} |
Latest revision as of 13:34, 27 January 2021
Apache OpenOffice Basic understands common mathematical, logical, and comparison operators.
Mathematical Operators
Mathematical operators can be applied to all numbers types, whereas the + operator can also be used to concatenate strings.
+ | Addition of numbers and date values, concatenation of strings |
& | Concatenation of strings |
- | Subtraction of numbers and date values |
* | Multiplication of numbers |
/ | Division of numbers |
\ | Division of numbers with a whole number result (rounded) |
^ | Raising the power of numbers |
MOD | modulo operation (calculation of the remainder of a division) |
Logical Operators
Logical operators allow you to do operations on elements according to the rules of Boolean algebra. If the operators are applied to Boolean values, the operation provides the result required directly. If used in conjunction with integer and long integer values, the operation is done at the bit level.
AND | And operator |
OR | Or operator |
XOR | Exclusive Or operator |
NOT | Negation |
EQV | Equivalent test (both parts True or False) |
IMP | Implication (if the first expression is true, then the second must also be true) |
Comparison Operators
Comparison operators can be applied to all elementary variable types (numbers, date details, strings, and Boolean values).
= | Equality of numbers, date values and strings |
<> | Inequality of numbers, date values and strings |
> | Greater than check for numbers, date values and strings |
>= | Greater than or equal to check for numbers, date values and strings |
< | Less than check for numbers, date values and strings |
<= | Less than or equal to check for numbers, date values and strings |
Content on this page is licensed under the Public Documentation License (PDL). |