11 - 382 11 - 382
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
SQR
Function
SQuare Root
• Returns the square root of the specified value.
SQR(<numeric expression>)
Syntax
numeric expression
• • • •
Specify the value for which the square root should be
obtained.
Examples
A=SQR(50)
• • • •
Assigns 50 (= 7.071067...) to A.
Description
• The SQR function returns the square root of the specified value.
• The value of <numeric expression> must be 0 or positive.
• The calculation of the SQR function is performed in single-precision.
Program Example
10 ' This program returns square root values
20 DIM A(10)
:
' Defines an array
30 PRINT "A(I)=","SQR(A(I))="
40 FOR I=1 TO 10
:
' Obtains the square root and displays it
50 A(I)=SQR(I)
60 PRINT I,
70 PRINT A(I)
80 NEXT I
RUN
A(I)= SQR(A(I))=
1 1
2 1.41421
3 1.73205
4 2
5 2.23607
6 2.44949
7 2.64575
8 2.82843
9 3
10 3.16228
OK