7 - 41
7 OPERATION CONTROL PROGRAMS
F/FS G
7.7.2 Unsigned 16-bit integer value conversion : USHORT
Format USHORT(S) Number of basic steps 2
[Usable data]
Usable Data
Word device Constant
Setting
data
Bit device
16-bit
integer
type
32-bit
integer
type (L)
64-bit
floating
point
type (F)
Coasting
timer
16-bit
integer
type (K/H)
32-bit
integer type
(K/H, L)
64-bit
floating
point
type (K)
Calculation
expression
Bit
conditional
expression
Comparison
conditional
expression
(S) —
— —
: Usable
[Setting data]
Setting data Description Data type of result
(S)
Data which will be converted into unsigned 16-bit
integer value
16-bit integer type
[Functions]
(1) The data specified with (S) is converted into an unsigned 16-bit integer value.
(2) The data range of (S) is 0 to 65535.
(3) When (S) is a 64-bit floating-point type, its fractional portion is rounded down
before conversion is made.
(4) If (S) is a 16-bit integer type, its value is returned unchanged, with no conversion
processing performed.
[Errors]
(1) An operation error will occur if:
• The (S) data is outside the range 0 to 65535; or
• (S) is an indirectly specified device and its device No. is outside the range.
[Program examples]
(1) Program which converts the data of D0L into an unsigned 16-bit integer value and
substitutes the result to #0
#0 = USHORT(D0L)
D1
K60000L
D0
(H0000EA60)
K-5536
#0
(HEA60)
Unsigned value is K60000