335
FX3S/FX3G/FX3GC/FX3U/FX3UC Series
Programming Manual - Basic & Applied Instruction Edition
12 Data Operation – FNC 40 to FNC 49
12.9 FNC 48 – SQR / Square Root
11
FNC30-FNC39
Rotation and
Shift
12
FNC40-FNC49
Data Operation
13
FNC50-FNC59
High-Speed
Processing
14
FMC60-FNC69
Handy
Instruction
15
FNC70-FNC79
External FX I/O
Device
16
FNC80-FNC89
External FX
Device
17
FNC100-FNC109
Data
Transfer 2
18
FNC110-FNC139
Floating Point
19
FNC140-FNC149
Data
Operation 2
20
FNC150-FNC159
Positioning
Control
12.9 FNC 48 – SQR / Square Root
Outline
This instruction obtains the square root.
The ESQR (FNC127) instruction obtains the square root in floating point operation.
→ For ESQR (FNC127) instruction, refer to Section 18.15.
1. Instruction format
2. Set data
: K0 to K32767 in 16-bit operation, K0 to K2,147,483,647 in 32-bit operation
3. Applicable devices
Explanation of function and operation
1. 16-bit operation (SQR and SQRP)
The square root of the data stored in is calculated, and stored to .
2. 32-bit operation (DSQR and DSQRP)
The square root of the data stored in [ +1, ] is calculated, and stored to [ +1, ].
Caution
1. Operation result
1) The obtained square root is an integer because the decimal point is ignored.
When the calculated value is ignored, M8021 (borrow flag) turns ON.
2) When the calculated value is true "0", M8020 (zero flag) turns ON.
Program example
Operand type Description Data type
Word device number storing data whose square root is obtained 16- or 32-bit binary
Data register number storing the square root operation result 16- or 32-bit binary
Oper-
and
Type
Bit Devices Word Devices Others
System User Digit Specification System User
Special
Unit
Index
Con-
stant
Real
Number
Charac-
ter String
Pointer
XYMTCSD.b KnX KnY KnM KnS T C D R U\G V Z Modify K H E ""P
DSQR
DSQRP
Mnemonic Operation Condition
P
FNC 48
SQR
D
16-bit Instruction
5 steps
SQR
SQRP
Mnemonic Operation Condition
Continuous
Operation
Pulse (Single)
Operation
32-bit Instruction
9 steps
Continuous
Operation
Pulse (Single)
Operation
S
1
S
D
D
1
S
S
1
S
D
D
1
S
D
1
D
Command
input
→
FNC 48
SQR
S
D
S
D
D
1
S
D
1
S
D
1
D
D
1
D
Command
input
+ 1,
FNC 48
DSQR
S
D
S
D
S
→
+ 1,
D
X000
S
D
D 10
→
D 12
FNC 48
SQR
D 10 D 12
100
→
10
=
The square root of D10 is stored to D12.
The value of D10 is "100".