11 - 2 11 - 2
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
11
ABS
Function
ABSolute
• Returns the absolute value of an arithmetic expression.
ABS ( <arithmetic expression> )
Syntax
arithmetic expression
• • • •
Specify the value to calculate the absolute value.
A=ABS( 3.14)
• • • •
Assigns 3.14 (absolute value of 3.14) to A.
B=ABS(0)
• • • •
Assigns 0 (absolute value of 0) to B.
Examples
C=ABS(3.14)
• • • •
Assigns 3.14 (absolute value of 3.14) to C.
Description
• The ABS function returns the absolute value of <arithmetic expression>.
• Returned values are always positive or 0.
• Returns a double precision number if a double precision real number is included in the
<arithmetic expression>, otherwise returns a single precision number.
Program Example
10 ' Calculates absolute value
20 A=-2.56
30 B=0
:
'Defines the value
40 C=2.56
50 PRINT "ABS(A)=";ABS(A)
60 PRINT "ABS(B)=";ABS(B)
:
'Displays the absolute value
70 PRINT "ABS(C)=";ABS(C)
80 END
RUN
ABS(A)= 2.56
ABS(B)= 0
ABS(C)= 2.56
OK