Operators
Operators
Types of Operators
・Operators that perform integer operations are described as "Int operators", and operators that perform floating point number operations are described as "Real operators".
・The logical operators return an Int 1 if the operation result is correct and an Int 0 if it is not correct.
・The logical operators with a shortcut skip the evaluation of the second expression when the operation result is determined by the evaluation result of the first expression.
() |
Parentheses |
[] |
Array Reference |
- (Unary) |
Additive Inverse |
+ |
Addition, String Concatenation |
ー (Term 2) |
Subtraction |
・ |
Multiplication, Repetition of String |
/ |
Division (Real Operator) |
DIV |
Int Division (Int Operator) |
MOD |
Remainder (Int Operator) |
<< |
Bitwise Left Shift (Int Operator) |
>> |
Bitwise Right Shift (Signed, Int Operator) |
<<< |
Bitwise Left Shift (Int Operator) |
>>> |
Bitwise Right Shift (Unsigned, Int Operator) |
<<+ |
Left Rotate (Int Operator) |
>>+ |
Right Rotate (Int Operator) |
AND |
Bitwise AND (Int Operator) |
OR |
Bitwise OR (Int Operator) |
XOR |
Bitwise XOR (Int Operator) |
NOT |
Bitwise NOT (Int Operator) |
== |
Equal (Logical Operator) |
!= |
Not Equal (Logical Operator) |
< |
Greater (Logical Operator) |
> |
Less (Logical Operator) |
<= |
Greater Equal (Logical Operator) |
>= |
Less Equal (Logical Operator) |
&& |
Logical AND with Shortcut (Logical Operator) |
|| |
Logical OR with Shortcut (Logical Operator) |
! |
Logical Negation (Logical Operator) |
Operator Precedence
The operator precedence is as follows.
() [] |
-(Unary) NOT ! |
・/ DIV MOD |
+ -(Binary) |
<< >> <<< >>> <<+ >>+ |
== != < <= > >= |
AND |
OR XOR |
&& |
|| |
(Expression)
Raise the priority of the expression in parentheses
Array[Expression [,…]]
Referencing array elements
・The number of expressions in [] is either 1 or the number of dimensions in the array.
- Numbers
Invert the sign of numbers
Number + Number
Add two numbers
String + String
Combine two strings
Number - Number
Subtract the right number from the left number
Number * Number
Multiply the left number by the right number
String * Int
Repeat the string by the right number
Number / Number
Divide the left number by the right number
・An error occurs if the number on the right is 0.
Int DIV Int
Divide the left number by the right number
・Unlike /, the result is always an Int.
・An error occurs if the number on the right is 0.
Example
A=201 DIV 5
Int MOD Int
The remainder of dividing the left number by the right number
・An error occurs if the number on the right is 0.
Example
A=201 MOD 5
Int AND Int
Bitwise AND of two Int
Example
A=200 AND &HE7
Int OR Int
Bitwise OR of two Int
Example
A = 128 OR &HA3
Int XOR Int
Bitwise XOR of two Int
Example
A=100 XOR &H4C
Int << Int
Shift left, the bits in the value of the left number, by the number of bits specified by the right number.
・Shifting left by 1 bit will double the value of the Int.
Example
A=100 << 2
Int >> Int
Shift right, the bits in the value of the left number, by the number of bits specified by the right number. (Signed)
・Shifting right by 1 bit will halve the value of the Int.
・Signs are taken into account. The signed bit (bit 31) does not change. The bit 30 will be copied with the bit 31.
Example
A=100 >> 2
B=-10 >> 1
Int <<< Int
Shift left, the bits in the value of the left number, by the number of bits specified by the right number.
・Shifting left by 1 bit will double the value of the Int.
・It operates exactly the same as <<.
A=100 <<< 2
Int >>> Int
Shift right, the bits in the value of the left number, by the number of bits specified by the right number. (Unsigned)
・Shifting right by 1 bit will halve the value of the Int.
・Unlike >>, the sign is not taken into account.
Example
A=100 >>> 2
B=-10 >>> 1
Int <<+ Int
Rotates left, the bits of the left value, by the number of bits specified by the right number.
・Unlike the Shift, the bit pushed out from the bit 31 is copied to the bit 0 side.
A= HEX$(&HFF00FF00 <<+ 8)
Int >>+ Int
Rotates right, the bits of the left value, by the number of bits specified by the right number.
・Unlike the Shift, the bit pushed out from the bit 0 is copied to the bit 31 side.
A= HEX$(&H00FF00FF >>+ 8)
NOT Int
Invert number bits
Number == Number
Returns 1 if the left and right numbers are equal, 0 if they are not equal
String == String
Returns 1 if the left and right strings are equal, 0 if they are not equal
Number != Number
Returns 1 if the left and right numbers are not equal, 0 if they are equal
String != String
Returns 1 if the left and right strings are not equal, 0 if they are equal
Number < Number
Returns 1 if the left number is less than the right number, 0 otherwise
String < String
Returns 1 if the left string is alphabetically less than the right string, 0 otherwise
Number > Number
Returns 1 if the left number is greater than the right number, 0 otherwise
String > String
Returns 1 if the left string is alphabetically greater than the right string, 0 otherwise
Number <= Number
Returns 1 if the left number is less than or equal to the right number, 0 otherwise
String <= String
Returns 1 if the left string is alphabetically less than or equal to the right string, 0 otherwise
Number >= Number
Returns 1 if the left number is greater than or equal to the right number, 0 otherwise
String >= String
Returns 1 if the left string is alphabetically greater than or equal to the right string, 0 otherwise
Expression && Expression
Returns 1 if the result of both expressions is true (!=0), 0 otherwise
・If the left expression is false (0), the calculation of the right expression is skipped and 0 is returned immediately.
Expression || Expression
Returns 1 if one of the two expression results is true (!=0), 0 otherwise
・If the left expression is true (!=0), the calculation of the right expression is skipped and 1 is returned immediately.
! Expression
Returns 0 if the result of the expression is true (!=0), 1 if it is false (0)