User Tools

Site Tools


en:operators

Operators

What is an operation and operator…

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.
2016/08/09 17:03 · 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
2016/08/09 10:21 · 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 10: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 10:16 · admin

Variable Operators

Most operators work with one or two expressions (integers, floating point numbers, strings, and Boolean values), but there are a few operators that work specifically with variables, arrays, and array elements. These operators will directly change the value stored in a variable.

Variable Operators
OperatorNameExampleComments
=Assign a Number to a Variablea = 9
z = “Hola.”
q$ = 9.9
+=Add to a Variablea += 7Same as a = a + 7
Concatenate to a Variablef += “.”Same as f = f + “.”
-=Subtract from a Variablea -= 9Same as a = a - 9
*=Multiply a Variablea *= 2Same as a = a * 2
/=Divide a Variablea /= 8Same as a = a / 8
++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)
++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)
Decrement Prefix–aDecrement (subtract one) the variable and return the value after the decrement. (may be applied ONLY to numeric variables or array elements)
Decrement 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)
fillArray Filla fill 99Fills an array (that was previously dimensioned) with a single value (may be a string or numeric expression)
2016/08/09 17: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 10:19 · admin

Order of Operations

Operators are evaluated according to a strict set of rules. These rules are called the “Order of Operations”.

Order of Operations
LevelOperatorsCategory/Description
1( )Grouping
2^Exponent
3- ~Unary Minus and Bitwise Negation (NOT)
4* / \Multiplication, Division, and Integer Division
5%Integer Remainder (Mod)
6+ - ;Addition/Concatenation, and Subtraction
7& |Bitwise And and Bitwise Or
8< ⇐ > >= = <>Comparison (Numeric and String)
9NOTNot
10ANDLogical And
11ORLogical Or
12XORLogical Exclusive Or
2016/08/09 17:33 · admin
en/operators.txt · Last modified: 2016/08/09 17:30 by admin