User Tools

Site Tools


en:operators

This is an old revision of the document!


Operators

The operators +, -, *, /, and ^ are used to perform addition, subtraction, multiplication, division, exponentiation of floating point and integer numbers. Valid operands are numeric constants and/or numeric variables.

The operators %, \, &, |, and ~ are used to calculate modulo, integer division, bitwise and, bitwise or, and bitwise negation (not) of integer expressions. Floating point numbers will be converted to an integer value before calculation.

The = operator is used both for assignment to variables, and to test for equality. The + operator may be used to perform concatenation of any combination of string constants and string variables. The : operator can separate multiple statements on a single line. The # operator is a shortcut for the Rem statement, and is interchangeable with it.

Arithmetic Operators
OperatorNameExampleComments
+Additiona + badd two numeric values. If one or both values are strings the plus operator will concatenate the strings into a single string.2
-Subtractiona - bsubtract two numeric values
*Multiplicationa * b
/Divisiona / bReturns a decimal number of times that b goes into a.
\Integer Divisiona \ bReturns the number of whole times that b goes into a.
%Moduloa % bReturns the remainder of the integer division of a and b.
++Increment Prefix++aIncrement (add one) the the variable and return the value after the increment. (may be applied ONLY to numeric variables or array elements) 1
++Increment Suffixa++Return the value of the variable and then increment the variable by one for the next time it is accessed. (may be applied ONLY to numeric variables or array elements) 1
Decrement Prefix–aDecrement (subtract one) the the variable and return the value after the decrement. (may be applied ONLY to numeric variables or array elements) 1
Decrrement Suffixa–Return the value of the variable and then decrement the variable by one for the next time it is accessed. (may be applied ONLY to numeric variables or array elements) 1


Arithmetic Operators

Arithmetic operators are simply the operations of simple math with integer and floating point numbers.

Arithmetic Operators
OperatorNameExampleComments
+Additiona + bAdd two numeric values. If both are an integer, then the result will be an integer. If one or both are floating point numbers then the result will be floating point. If one or both values are strings the plus operator will concatenate the strings.2
-Subtractiona - bSubtract two numeric values. If both were integer and the operation did not overflow then an integer will be returned else a floating point number will be the result.
*Multiplicationa * bMultiply the two numbers. If both were integer and the operation did not overflow then an integer will be returned else a floating point number will be the result.
/Divisiona / bReturns a floating point number of times that b goes into a.
\Integer Divisiona \ bReturns the number of whole times that b goes into a.
%Moduloa % bReturns the remainder of the integer division of a and b.
moda mod b

History

2.0.0.0Added 'mod' alias for modulo.
2016/08/09 18:03 · admin

Comparison Operators

Comparison operators compare two values and return a Boolen (true/false) value. These Operators are most commonly used in statements like If, Case and While.

Comparison Operators
OperatorNameExampleComments
=Equala = bReturns true of two values are equal
<Less Thana < b
>Greater Thana > b
<=Less Than or Equala <= b
>=Greatet Than or Equala >= b
<>Not Equala <> b
2016/08/09 11:02 · admin

Logical Operators

Logical operators work on Boolean (true/false) values. These values often come as Boolean Constants and Comparison Operators.

Logical Operators
OperatorNameExampleComments
NOTLogical NegationNOT a
ANDLogical Conjunctiona AND b
ORLogical Disjunctiona OR b
XORLogical Exclusive Disjunctiona XOR b

Not

Also known as Boolean negation.

not truefalse
not falsetrue

And

Also known as a Boolean product.

false and falsefalse
false and truefalse
true and falsefalse
true and truetrue

Or

Also known as Boolean addition.

false or falsefalse
false or truetrue
true or falsetrue
true or truetrue

Xor

The exclusive or. “You can have you cake XOR you can eat it.”

false xor falsefalse
false xor truetrue
true xor falsetrue
true xor truefalse
2016/08/09 11:16 · admin

Bitwise Operators

Bitwise operators only work with long integer values (since 1.99.99.19) in the range of −2,147,483,648 to 2,147,483,647. Any attempt to use a number outside this range will produce, warnings, error, and/or unexpected results.

Bitwise Operators
OperatorNameExampleComments
~Bitwide Negation~a
&Bitwise Conjunctiona & bIf one or both values are strings the ampersand operator will concatenate the strings into a single string.3
|Bitwise Disjunctiona | bReturns the bits of integer a or integer b.
2016/08/09 11:19 · admin

String Operators

String operators perform an operation called concatenation. Concatenation is joining two or more strings together to make a longer string.

String Operators
OperatorNameExampleComments
;Concatenationa ; bAlways concatenates (converts numbers to strings)2
+Concatenationa + bAppends b to the end of a (If either (or both) a and b are not numbers, see IsNumeric). 2
&Concatenationa & bAppends b to the end of a (If either (or both) a and b are not numbers, see IsNumeric). 3
*Repeata * iRepeats string a, integer i times. If i ⇐ 0 an empty string will be returned.

History

2.0.0.0Added string repeat using the '*' operator.
2016/08/09 11:21 · admin
Order of Operations
LevelOperatorsCategory/Description
1( )Grouping
2^Exponent
3- ~Unary Minus and Bitwise Negation (NOT)
4* / \Multiplication and Division
5%Integer Remainder (Mod)
6+ -Addition/Concatenation, and Subtraction
7& |Bitwise And and Bitwise Or
8< ⇐ > >= = <>Comparison (Numeric and String)
9NOTUnary Not
10ANDLogical And
11ORLogical Or
12XORLogical Exclusive Or


1 new with version 1.9.9.10
2 new or changed with version 1.9.9.30
3 new or changed with version 1.9.9.30

en/operators.1470787198.txt.gz · Last modified: 2020/02/28 10:46 (external edit)