Math operators

Proton PIC Basic V3.0

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.
ABS Returns the absolute value of a number.
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 Returns the specified decimal digit of a positive value.
EXP Deduce the exponential function of a value.
LOG Returns the NATURAL LOG of a value.
LOG10  Returns the LOG of a value.
MAX Returns the maximum of two numbers.
MIN Returns the minimum of two numbers.
NCD Priority encoder of a 16-bit value.
POW Computes variable to the power of pow variable.
REV Reverses the order of the lowest bits in a value.
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!)