User Manual

MCP Series
Brushed DC Motor Controllers
MCP Series User Manual
133
Subtraction (-)
Subtract a value (integer or oating point) from another value. The resulting number is not
signed unless a signed variable is used. An example of subtraction:
time var byte
time = 100
time = time - 1
The variable time will now equal 99 since we subtracted 1 from 100.
Addition (+)
Add one value (integer or oating point) to another value. The resulting number is not signed
unless a signed variable is used. An example of addition:
time var byte
time = 100
time = time + 1
The variable time will now equal 101 since we added 1 to 100.
Multiplication (*)
Multiply one value (integer or oating point) by another value. The resulting number is not
signed unless a signed variable is used. An example of multiplication:
time var byte
time = 100
time = time * 1
The variable time will now equal 100 since we multiplied 100 by 1.
Division (/)
Divide one value (integer or oating point) by another value. Integer division discards fractional
results. For example:
result = 76/7
will set the variable “result” to a value of 10. (The actual decimal result would be 10.857, but the
decimal part is discarded, rounding is not done.) If your application requires fractional results
you can use oating point numbers or the following solution.
Use a oating point variable instead to get the full precision.
result var oat
result = 76.0/7.0