User Manual

MCP Series
Brushed DC Motor Controllers
MCP Series User Manual
143
TOINT
The TOINT operator explicitly converts a oating point value into an integer value. The decimal
point of the oating point number is truncated.
myoat var oat
myint var long
myoat = 10.0 ;myoat now equals 10.0
myoat = myoat * 123.123 ;myoat now equals 1231.23
myint = TOINT myoat ;myint now equals 1231
serout s_out,i9600,[“result = “,sdec myint,13]
TOFLOAT
The TOFLOAT operator explicitly converts an integer value into a oating point value.
myint var long
myoat var oat
myint = 10
myoat = TOFLOAT myint / 100.0 ;myoat now equals 0.1
serout s_out,i9600,[“result = “,real myoat,13]
FABS
The Absolute Value (ABS) converts a signed number to its absolute value. The absolute value of
a number is the value that represents its difference from 0. The absolute value of -4 is 4. If the
number is positive the result will always be the same number returned:
temp = fabs(-1234.1234)
temp = fabs(1234.1234)
In the example above, the result will always be 1234.1234.
FSQRT
FSQRT returns the oating point square root of the argument. A square root is the number, that
when multiplied by itself will equal the original argument.
If the value of “num” is 2, the following statement will return the value of 1.4142:
myoat var oat
myoat = FSQRT 2.0
serout s_out,i9600,[“result = “,real myoat,13]