User manual

218
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Arithmetic Operators Overview
Operator Operation Operands Result
+
addition
byte, short, word, integer,
longint, longword, oat
byte, short, word, inte-
ger, longint, longword,
oat
-
subtraction
byte, short, word, integer,
longint, longword, oat
byte, short, word, inte-
ger, longint, longword,
oat
*
multiplication
byte, short, word, integer,
longint, longword, oat
word, integer, longint,
longword, oat
/
division, oating-point
byte, short, word, integer,
longint, longword, oat
oat
div
division, rounds down to near-
est integer
byte, short, word, integer,
longint, longword
byte, short, word, inte-
ger, longint, longword
mod
modulus, returns the remain-
der of integer division (cannot
be used with oating points)
byte, short, word, integer,
longint, longword
byte, short, word, inte-
ger, longint, longword
Division by Zero
If 0 (zero) is used explicitly as the second operand (i.e. x div 0), the compiler will report an error and will not gener-
ate code.
But in case of implicit division by zero: x div y, where y is 0 (zero), the result will be the maximum integer (i.e 255,
if the result is byte type; 65536, if the result is word type, etc.).
Unary Arithmetic Operators
Operator - can be used as a prex unary operator to change sign of a signed value. Unary prex operator + can be
used, but it doesn’t affect data.
For example:
b = -a