
Bitwise operators operate on 32 bit signed integer values.
The Avisaro Scripting Language supports these four bitwise operators:
AND
A bitwise AND takes two signed integers and performs the logical AND operation on each pair of corresponding bits. In each pair, the result is 1 if the first bit is 1 AND the second bit is 1. Otherwise, the result is 0. In the Avisaro Scripting Language, one can use the keyword AND or the abbreviation & to perform an AND operation.
OR
A bitwise OR takes two signed integers andproduces another one by matching up correspondingbits (the first of each; the second of each; and so on) and performingthe logical inclusive OR operation on each pair of corresponding bits. In each pair, the result is 1 if the first bit is 1 OR the second bit is 1 (or both), and otherwise the result is 0. In the Avisaro Scripting Language, one can use the keyword OR or the abbreviation | to perform an OR operation.
Exclusive OR
A bitwise exclusive OR takes two signed integers and performs the logical exclusive OR operation on each pair of corresponding bits. The result in eachposition is 1 if the two bits are different, and 0 if they are the same. In the Avisaro Scripting Language, one can use the keyword EOR or the abbreviation @ to perform an exclusive OR operation.
NOT
The bitwise NOT, or complement, is a unary operation which performs logical negation on each bit, forming the ones' complement of the given binary value. Digits which were 0 become 1, and vice versa. In the Avisaro Scripting Language, one can use the keyword NOT or the abbreviation ~ to perform a NOT operation.
outmode -2 let a = 1 print a let a = a EOR 1 print a let a = a EOR 1 print a let a = a OR 2 print a let a = a AND 2 print a let a = NOT 48 print a
Prints out six lines with the values 1,0,1,3,2 and -49
The scripting engine supports the usual arithmetic operators Multiplication, Division, Addition, Subtraction and Modulo. All these operators work with 32 bit signed integers, which is the only numeric data type of the scripting engine.
+ (Addition) Performs the standard mathematical process of putting two numbers together.
- (Subtraction) Performs the standard mathematical "inverse addition" of two numbers.
/ (Division) Performs the standard mathematical "inverse multiplication" of two numbers.
* (Multiplication) Performs the standard mathematical operation of adding together multiple copies of the same number.
% (Modulo) -- Version 3.26 and above. Gives the remainder of division of one number by another.
outmode -2 let a = 13 let b = 4 print a print "+" print b print "=" print a+b print a print "-" print b print "=" print a-b print a print "/" print b print "=" print a/b print a print "%" print b print "=" print a%b
Prints out the four lines:
13+4=17 13-4=9 13/4=3 13%4=1
The scripting engine supports a number of relational (or comparison) operators in order to test the relation between two 32 bit signed integer numbers. Relational Operators are normally used in conditional control statements (IF/THEN/ELSE) and iterations (loops).
Supported operators are:
= (equal to) Tests if two values are.
<> (not equal to) Tests if two values are nor equal.
> (greater than) Test if the value of the left expression is greater than that of the right.
< (less than) Test if the value of the left expression is less than that of the right.
>= (greater or equal) Test if the value of the left expression is greater than or equal to that of the right.
<= (less or equal) Test if the value of the left expression is less than or equal to that of the right.
outmode -2 let a = -5 while a <= 5 print a a = a + 1 wend end
Prints out all numbers between (and including) -5 ... 5
When using the plus sign + on string literals and variables, it produces a result string that contains both operands linked together.
outmode -2 let a$ = "hello " let b$ = "world" let c$ = a$ + b$ print c$ end
Prints out the content of c$ which becomes "hello world" after a$ and b$ are joined.