7-288
SQR(P)
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.
• The value designated by is a negative number. (Error code: 4100)
• The contents of the designated device or the result of the addition are not "0", or not within
the following range(For the Universal model QCPU only): (Error code: 4140)
0, 2
-126
| Contents of designated device | < 2
128
• The value of the specified device is 0.
*3
(For the Basic model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU, and Q4ARCPU) (Error code: 4100)
*3: There are CPU modules that will not result in an operation error if 0 is specified. For details, refer to 3.2.4.
• The result exceeds the following range (Operation results in an overflow)
(For the Universal model QCPU only)
2
128
| Operation result | (Error code: 4141)
• The value of the specified device is 0, unnormalized number, nonnumeric, and ± .
(For the Universal model QCPU only) (Error code: 4140)
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]
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