6-31
6 Programming
NJ-series CPU Unit Software User’s Manual (W501)
6-3 Variables
6
6-3-5 Data Types
There are two kinds of data types: basic data types, which have predefined specifications, and deriva-
tive data types, which are defined according to user specifications.
Basic Data Types
The different kinds of basic data types are listed below.
There are a total of twenty different basic data types. The specifications are given in the following
table.
The meanings of the data size and alignment columns in the following table are as follows:
• Data size: The actual size of the value.
• Alignment: The unit used to allocate memory.
Basic Data Types and Derivative Data Types
Classification Definition
Boolean A data type with a value of either TRUE or FALSE.
Bit string A data type that represents a value as a bit string.
Integer A data type that represents an integer value.
Real number A data type that represents a real number.
Duration
A data type that represents a time duration (days, hours, minutes, seconds, and
milliseconds).
Time of day A data type that represents a specific time of day (hour, minutes, and seconds).
Date A data type that represents a date (year, month, and day).
Date and time
A data type that represents a date and time (year, month, day, hour, minutes,
seconds, and milliseconds).
Text string A data type that contains a value that represents a text string.
Classification Data type Data size Alignment Range of values Notation
Boolean BOOL 16 bits 2 bytes FALSE or TRUE BOOL#1, BOOL#0, TRUE or FALSE
Bit strings
BYTE 8 bits 1 byte BYTE#16#00 to FF BYTE#2#01011010
BYTE#2#0101_1010
BYTE#16#5A
You can also use the “_” character as a
separator.
WORD 16 bits 2 bytes WORD#16#0000 to FFFF
DWORD
32 bits 4 bytes DWORD#16#00000000 to
FFFFFFFF
LWORD
64 bits 8 bytes LWORD#16#0000000000000000
to FFFFFFFFFFFFFFFF
Integers
SINT 8 bits 1 byte SINT#-128 to +127 100
INT#2#00000000_01100100
INT#8#144
INT#10#100
INT#16#64
100
INT 16 bits 2 bytes INT#-32768 to +32767
DINT
32 bits 4 bytes DINT#-2147483648 to
+2147483647
LINT
64 bits 8 bytes LINT#-9223372036854775808 to
+9223372036854775807
USINT 8 bits 1 byte USINT#0 to +255
UINT 16 bits 2 bytes UINT#0 to +65535
UDINT 32 bits 4 bytes UDINT#0 to +4294967295
ULINT
64 bits 8 bytes ULINT#0 to
+18446744073709551615