6 Programming
6-32
NJ-series CPU Unit Software User’s Manual (W501)
*1 Use the NanoSecToTime and TimeToNanoSec instructions to convert between durations and integer data. Refer to the
NJ-series Instructions Reference Manual (Cat. No. W502) for detailed instruction specifications.
*2 Variables are compared with nanosecond precision for comparison instructions. To change the precision for comparison,
use the TruncTime, TruncDt, or TruncTod instruction.
*3 A NULL character (1 byte) is added to the end of text strings. Therefore, reserve memory for one more character than the
number of handled characters. For example, if a maximum of 10 single-byte characters are handled, define a STRING
variable for 11 characters (11 bytes). STRING[11]
*4 If you want to insert tabs, line break codes, or other special characters, you can use a single-byte dollar sign ($) as an
escape character before them. Refer to Escape Character List on page 6-70 for a list of the escape characters.
Real numbers
REAL
32 bits 4 bytes REAL#3.402823e+38 to
1.175495e-38
0
1.175495e-38 to 3.402823e+38
+ /
REAL#3.14
LREAL#3.14
3.14
3.14
1.0E+6
1.234e4
LREAL
64 bits 8 bytes LREAL#1.79769313486231e
+308 to 2.22507385850721e-308
0
2.22507385850721e-308 to
1.79769313486231e+308
+ /
Durations
*1*2
TIME
64 bits 8 bytes T#-9223372036854.775808ms
(T#-
106751d_23h_47m_16s_854.7758
08ms) to
T#+9223372036854.775807ms
(T#+106751d_23h_47m_16s_854.
775807ms)
T#12d3h3s
T#3s56ms
TIME#6d_10m
TIME#16d_5h_3m_4s
T#12d3.5h
T#10.12s
T#61m5s (Equivalent to T#1h1m5s)
TIME#25h_3m
Date DATE
64 bits 8 bytes D#1970-01-01 to D#2106-02-06
(January 1, 1970 to February 6,
2106)
Add “DATE#”, “date#”, “D#”, or “d#” to the
beginning of the string and express the
date in the yyyy-mm-dd format.
Example:
d#1994-09-23
Time of day
*2
TIME_OF
_DAY
64 bits 8 bytes TOD#00:00:00.000000000 to
TOD#23:59:59.999999999
(00:00:0.000000000 to
23:59:59.999999999)
Add “TIME_OF_DAY#”, “time_of_day#”,
“TOD#”, or “tod #” to the beginning of the
string and express the time of day in the
hh-mm-ss format.
Example:
tod#12:16:28.12
Date and
time
*2
DATE_
AND_
TIME
64 bits 8 bytes DT#1970-01-01-
00:00:00.000000000 to DT#2106-
02-06-23:59:59.999999999 (Janu-
ary 1, 1970 00:00:0.000000000 to
July 21, February 6, 2106,
23:59.999999999 seconds.)
Add “DT#” or “dt#” to the beginning of the
string and express the date and time in the
yyyy-mm-dd-hh:mm:ss format.
Example:
dt#1994-09-23-12:16:28.12
Text strings STRING
(Number of
single-byte
characters
plus 1) 8
bits
*3
1 byte The character code is UTF-8.
0 to 1,986 bytes (1,985 single-byte
alphanumeric characters plus the
final NULL character, for Japanese,
this is approximately equal to 0 to
661 characters)
*4
The default size is 256 bytes.
Enclose the string in single-byte single
quotation marks (‘).
Example:
‘OMRON’‘PLC’
Classification Data type Data size Alignment Range of values Notation