Math Functions = + – * / % ( )

= Assignment The number or value on the right side is saved into the variable on the left side
+ Add Add the two number values
Subtract Subtract the second number from the first number
* Multiple Multiply two numbers
/ Divide Divide the first number by the second number
% Modulo Remainder of first number divided by second number
( ) Precedence Any values inside brackets will be calculated before values outside the brackets


All math calculations and variables use signed 16 bit integer values, which means all numbers are in the range -32768 to +32767 . This is because the MSP430 microcontroller uses a 16 bit data bus, and the minimum number and the maximum number that can be used is -2**15  to +2**15  .  (2 raised to the power 15).

 

Examples


a = 3
b = 4
c = (27+a)/(( 945*b) - 54)
print 'the answer to this difficult sum is', c
a = 13 % 5
print ' 13 remainder 5 is', a