ZBasic Language Reference
30
ZBasic Microcontrollers
b = (b 5) + 3
b = b (5 + 3)
The parentheses indicate that the expression within should be evaluated first after which the result may
be used as an operand in another operation.
2.4.3 Arithmetic Operators
The arithmetic operators are listed in the table below along with the permitted operand types. The result
is the same type as the operands.
Arithmetic Operators
Function
Type
Operator
Permitted Operand Types
Negation
Unary
-
any numeric
Addition
Binary
+
any numeric
Subtraction
Binary
-
any numeric
Multiplication
Binary
*
any numeric¹
Division, Integer
Binary
\
any integral¹
Division, Real
Binary
/
Single
Modulus
Binary
Mod
any numeric¹
Exponentiation
Binary
^
any numeric²
Notes:
¹ In BasicX mode, operating on UnsignedLong is not supported.
² The result will be the same type as the left operand. In BasicX mode, the left
operand must be Single and the right operand must be either Single or Integer.
For Single operands, dividing by zero produces a special value indicating either positive or negative
infinity depending on the sign of the dividend. Dividing 0.0 by 0.0 produces a special value called NaN,
representing a value that is Not a Number. Similarly, performing the Mod operation with Single values
using a divisor of zero produces a NaN. For all other operand types the result of using a zero divisor for
either division or Mod is undefined. The System Library function SngClass() returns a value indicating
the general classification of a value of type Single. See the description of SngClass() in the System
Library Reference Manual for more information.
2.4.4 Logical Operators
The logical operators are listed in the table below along with the permitted operand types. The result is
the same type as the operand(s).
Logical Operators
Function
Type
Operator
Permitted Operand Types
Logical AND (conjunction)
Binary
And
Boolean
Bitwise AND
Binary
And
any integral¹
Logical OR (disjunction)
Binary
Or
Boolean
Bitwise OR
Binary
Or
any integral¹
Logical XOR (exclusive disjunction)
Binary
Xor
Boolean
Bitwise XOR
Binary
Xor
any integral¹
Logical Complement
Unary
Not
Boolean
Bitwise Complement
Unary
Not
any integral¹
Notes:
¹ If Option Strict is enabled, signed types are not allowed.
|