Moog Animatics SmartMotor™ Developer's Guide,Rev. L
Page 262 of 909
avoided by only displaying nine rounded digits after the decimal place. This allows for small
numbers (less than 100000) to show all nine decimal digits.
When using floating-point values or floating-point variables in equations, there are some rules
to be aware of. The equation parser will not perform floating-point operations until at least
one of the input values is a floating-point value. After a floating-point value is seen, the
following operations (in the order of operations) in that equation will proceed with floating-
point operations. Note that it is a common mistake to divide two integers and expect a
floating-point result — at least one of those input values must be entered as a floating-point
value or first multiplied by 1.0, to invoke floating-point operations.
Floating-point variables will remember the full range possible but can only display a limited
range. The display is limited to nine digits after the decimal point, and -2147483648 to
2147483647 before the decimal point.
When assigning a floating-point variable to an integer, the integer cannot accept a value
outside of the range: -2147483648 to 2147483647. This will result in a command error (Code
23: Math Overflow) and the integer will remain at its previous value.
A floating-point number can be assigned to an integer, but it will round toward 0. For
example, the value 1.9 becomes 1; the value -1.9 becomes -1.
Basic math operations (+, -, *, /) are performed at 64-bit precision. However, the
trigonometric functions are only calculated with 32-bit precision.
For more details, see Variables and Math on page 195.
EXAMPLE:
af[0]=123.5 'Assign the value of 123.5 to af[0].
Raf[0]
af[0]=1/10 'Perform the integer divide and store result to af[0].
Raf[0]
af[0]=1.0/10 'Perform the floating-point divide and store
'result to af[0].
Raf[0]
af[0]=1300000.0*2700000 'The product would overflow a 32-bit integer,
'but af[0] can handle it.
a=af[0]/1000000 'Reduce the size of the value to something an
'integer can handle.
Ra
a=(1300000.0*2700000)/1000000 'This has the same result; the equation
'still performs a floating-point divide
'and stores the integer result.
Ra
END
Program output is:
123.500000000
0.000000000
0.100000000
3510000
3510000
Part 2: Commands: af[index]=formula