Math operators

Proton PIC Basic V3.5

To ensure the operations are carried out in the correct order use parenthesis to group the operations:

 A = ((B - C) * (D + E)) / F 

 
+ Adds variables and/or constants.
- Subtracts variables and/or constants.
* Multiplies variables and/or constants.
** Returns the high 16 bits of a 16-bit multiply result.
*/ Returns the middle 16 bits of a 16-bit multiply result.
/ Divides variables and/or constants.
// Modulus; returns the remainder left after a dividing one value by another.
& Bitwise AND.
| Bitwise OR.
^ Bitwise XOR.
~ Bitwise NOT A = ~B ( (complement) inverts the bit(s) of a number)
<< Shifts the bits of a value left a specified number of places.
>> Shifts the bits of a value right a specified number of places.
@ Bitwise reverse (Reverses the order of the lowest bits in a value).
? Returns the specified decimal digit of a positive value.
ABS Returns the absolute value of a number.
fABS Returns the absolute value of a number as FLOAT.
ACOS Returns the ARC COSINE of a value in radians.
ASIN Returns the ARC SINE of a value in radians.
ATAN Returns the ARC TANGENT of a value in radians.
COS Returns the COSINE of a value in radians.
DCD 2 n -power decoder of a four-bit value.
DIG Obsolete command (see '?').
EXP Deduce the exponential function of a value.
ICOS Returns the COSINE of an integer value in radians.
ISIN Returns the SINE of an integer value in radians.
ISQR Returns the SQUARE ROOT of an integer value.
LOG Returns the NATUREAL LOG of a value.
LOG10  Returns the LOG of a value.
NCD Priority encoder of a 16-bit value.
POW Computes variable to the power of pow variable.
REV Obsolete command (see '@').
fROUND Round a value to the nearest integer.
SIN Returns the SINE of a value in radians.
SQR Returns the SQUARE ROOT of a value.
TAN Returns the TANGENT of a value in radians.
DIV32 15-bit x 31-bit divide. (For PBP compatibility only)


Boolean logic operators

Logic operators (Boolean functions) can be used to test the results from more than one comparison to TRUE or FALSE, the result can be used to make a decision concerning the running program.

AND 
OR
XOR Exclusive OR
NOT Inverts the outcome of a condition (TRUE becomes FALSE, FALSE becomes TRUE)

Relational operators

Relational operators are used to compare two values, the result can be used to make a decision regarding program flow.

= Equal to
== Equal to (same as =)
<> Unequal to
!= Unequal to (same as <>)
< Smaller than
> Greater than
<=  Smaller than or equal to (Note: <= is correct, =< is incorrect!)
>= Greater than or equal to (Note: >= is correct, => is incorrect!)