7-307
BSQR(P),BDSQR(P)
1
2
3
4
6
6
7
8
7.12 Special function instructions
7.12.28 BCD 4-digit and 8-digit square roots (BSQR(P),BDSQR(P))
BDSQR
(1) Calculates the square root of the values designated by and +1 and stores the results at
the device designated by .
(2) BCD value of a maximum of 8 digits (0 to 99999999) can be designated by and +1.
(3) The operation results of and +1 are stored as their respective BCD values of between
0 and 9999.
(4) Operation results are rounded off from the fifth decimal place.
For this reason, the fourth decimal place has an error of
±1.
Operation Error
(1) In the following case, an operation error occurs, the error flag (SM0) turns ON, and an error
code is stored into SD0.
• The data designated by is not a BCD value. (Error code: 4100)
Program Example
(1) The following program calculates the square root of BCD value 1325 and outputs the integer
part to the 4 BCD digits from Y50 to Y5F, and the decimal fraction part to the 4 BCD digits
from Y40 to Y4F.
[Ladder Mode]
[List Mode]
[Operation]
S S
D
+1
D
S
D
(
)
2-word data
+1
Integer part
Decimal fraction part
.
S
S S
D D
S
Sets the data used for
square root operation ( )
Executes square root operation ( )
Outputs the integer part of the operation
result to a display device ( )
Outputs the decimal fraction part of the
operation result to a display device ( )
1
2
3
4
Step Instruction Device
BSQR operation
BSQR
D1
BCD value
0036
D2
BCD value
4005
D0
BCD value
1
32
5
MOV
1325
H
Y5F
BCD value
0036
Y50
Y4F
BCD value
4005
Y40
Transfer
MOV
Transfer
Integer part
Decimal fraction part