Flexible NC programming
1.7 Comparison and logical operations
Job planning
Programming Manual, 03/2006 Edition, 6FC5398-2BP10-1BA0
1-23
Parameters
TRUNC() Truncate decimal places
Relative equality considered 10
-12
for
• Equality: (==)
• Inequality: (<>)
• Greater than or equal to: (>=)
• Less than or equal to: (<=)
• Greater/less than: (><) with absolute equality
• Greater than: (>)
• Less than: (<)
Compatibility
For compatibility reasons, the check for relative equality with (>) and (<) can be deactivated
by setting machine data MD 10280: PROG_FUNCTION_MASK Bit0 = 1.
Note
Comparisons with data of type REAL are subject to a certain imprecision for the above
reasons. If deviations are unacceptable, use INTEGER calculation by multiplying the
operands by a precision factor and then truncating with TRUNC.
Synchronized actions
The response described for the comparison commands also applies to synchronized actions.
Example: precision considerations
N40 R1=61.01 R2=61.02 R3=0.01 ;Assignment of initial values
N41 IF ABS(R2-R1) > R3 GOTOF ERROR ;Jump was performed previously
N42 M30 ;End of program
N43 ERROR: SETAL(66000)
R1=61.01 R2=61.02 R3=0.01 ;Assignment of initial values
R11=TRUNC(R1*1000) R12=TRUNC(R2*1000)
R13=TRUNC(R3*1000)
;Precision correction
IF ABS(R12-R11) > R13 GOTOF ERROR ;Jump is no longer executed
M30 ;End of program
ERROR: SETAL(66000)