528
SQR, SQRP
F
unct
i
on
(1) Returns the square root of the value designated at , and stores the operation result in the device number designated at
.
(2) Only positive values can be designated by . (Operation cannot be performed on negative numbers.)
Operat
i
on
E
rror
(1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and an error code is stored into
SD0.
*2:
There are CPU modules that will not result in an operation error if -0 is specified.
For details, refer to Page 88, Section 3.2.4.
Program
E
xamp
l
e
(1) The following program seeks the square root of the value set by the 4 BCD digits from X20 to X2F, and stores the result
as a 32-bit floating decimal point type real number at D0 and D1.
[Ladder Mode]
[List Mode]
[Operations involved when value designated by X20 to X2F is 650]
Error
code
Error details
Q00J/
Q00/
Q01
QnH
QnPH QnPRH
QnU
LCPU
4100
The value specified in is negative.
––
The specified device value is -0.
*2
––
––
4140
The specified device value is not within the following range:
0, 2
-126
| Specified device value | < 2
128
The specified device value is -0, unnormalized number, nonnumeric, or
±
.
––
––
––
––
4141
The operation result exceeds the following range (when an overflow
occurs):
2
128
| Operation result |
––
––
––
––
S
D
+1
+1
S
D
S
D
(
)
32-bit floating-point
real number
32-bit floating-point
real number
S
S
Inputs data used for
square root operation ( )
Con
v
erts the input data into a
32-bit floating-point real number ( )
Executes square root
operation ( )
1
2
3
Step
I
nstruct
i
on
De
vi
ce
X2
F
BCD
v
a
l
ue
0
D20
6 5 0
X20
Con
v
ers
i
on
to
B
IN
B
IN
b15
b0
B
IN v
a
l
ue
650
Con
v
ers
i
on
to
f
l
oat
i
ng
-
po
i
nt
FLT
S
Q
R
operat
i
on
D11
D10
S
Q
R
D1
D0
6 5 0
2 5
. 4
9 5 1
1
2
3