
16.CUSTOM MACRO PROGRAMMING B-63944EN/02
- 416 -
Limitation
• Caution concerning decreased precision
When bit 0 (F16) of parameter No. 6008 is set to 0
• Addition and subtraction
Note that when an absolute value is subtracted from another
absolute value in addition or subtraction, the relative error may
become 10
-15
or greater.
For example, assume that #1 and #2 have the following true values
in the process of operation.
(The following values are examples in the process of operation and
cannot actually be specified from any program.)
#1=9876543210.987654321
#2=9876543210.987657777
You cannot obtain the following result with operation #2-#1:
#2-#1=0.000003456
This is because the precision of custom macro variables is 15
decimal digits. With this precision, the values of #1 and #2
become:
#1=9876543210.987650000
#2=9876543210.987660000
(Precisely, the actual values are slightly different from the above
values because they are internally processed in binary.) Therefore,
the result is:
#2-1=0.000010000
A large error occurs.
• Logical expressions
Be aware of errors that can result from conditional expressions
using EQ, NE, GT, LT, GE, and LE because they are processed
basically in the same way as addition and subtraction. For
example, if the following statement is used to decide whether #1 is
equal to #2 in the above example, a correct decision may not be
resulted because errors may occur:
IF [#1 EQ #2]
Evaluate the difference between #1 and #2 with:
IF [ABS [#1-#2]LT 0.1]
Then, assume that the values are equal when the difference does
not exceed the allowable error range.
• Trigonometric functions
The absolute error is guaranteed for trigonometric functions.
However, the relative error is 10
-15
or greater. Carefully perform
multiplication or division after executing a trigonometric function.
• FIX function
When using the FIX function for the result of an operation, be
careful with the precision. For example, when the following
operations are performed, the value of #3 may not always be 2.
N10 #1=0.002;
N20 #2=#1*1000;
N30 #3=FIX[#2];