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.
myoat var oat
myint var long
myoat = 10.0 ;myoat now equals 10.0
myoat = myoat * 123.123 ;myoat now equals 1231.23
myint = TOINT myoat ;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
myoat var oat
myint = 10
myoat = TOFLOAT myint / 100.0 ;myoat now equals 0.1
serout s_out,i9600,[“result = “,real myoat,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:
myoat var oat
myoat = FSQRT 2.0
serout s_out,i9600,[“result = “,real myoat,13]