528
SQR, SQRP
Function
(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.)
Operation Error
(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 Example
(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 DS D
(
)
32-bit floating-point
real number
32-bit floating-point
real number
S
S
Inputs data used for
square root operation ( )
Converts the input data into a
32-bit floating-point real number ( )
Executes square root
operation ( )
1
2
3
Step Instruction Device
X2F
BCD value
0
D20
650
X20
Conversion
to BIN
BIN
b15
b0
BIN value
650
Conversion to
floating-point
FLT
SQR operation
D11 D10
SQR
D1 D0
650 25
.
4 951
1
2
3