541
BSQR, BSQRP, BDSQR, BDSQRP
1
2
3
4
4
6
7
8
7.12 Special function instructions
7.12.28 BSQR, BSQRP, BDSQR, BDSQRP
Function
BSQR
(1) Returns the square root of the value designated at , and stores the operation result in the device number designated at
.
(2) Values that can be designated at are BCD values with a maximum of 4 digits (from 0 to 9999).
(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.
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.
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]
Error
code
Error details
Q00J/
Q00/
Q01
QnH QnPH QnPRH QnU LCPU
4100
The data specified in is not a BCD value.
––
S
D
+1
D
S
D
Integer part
Decimal fraction part
.
S
D D
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