Data types
A data type is a classification that defines for literals and variables the possible values, the operations that can be performed, and the way the values are stored.
This page covers the elementary data types. To build your own types — structures, enumerations, arrays, subranges, sized strings and references — see derived types.
| Data type | Description | Default value |
|---|---|---|
BOOL | Boolean | 0, FALSE |
SINT | Short integer | 0 |
INT | Integer | 0 |
DINT | Double integer | 0 |
LINT | Long integer | 0 |
USINT | Unsigned short integer | 0 |
UINT | Unsigned integer | 0 |
UDINT | Unsigned double integer | 0 |
ULINT | Unsigned long integer | 0 |
REAL | Real numbers | 0.0 |
LREAL | Long real numbers | 0.0 |
TIME | Duration | T#0s |
LTIME | Duration | LTIME#0s |
DATE | Date | DATE#1970-01-01 |
LDATE | Long date | LDATE#1970-01-01 |
TIME_OF_DAY or TOD | Time of day | TOD#00:00:00 |
LTIME_OF_DAY or LTOD | Time of day | LTOD#00:00:00 |
DATE_AND_TIME or DT | Date and time of day | DT#1970-01-01-00:00:00 |
LDATE_AND_TIME or LDT | Date and time of day | LDT#1970-01-01-00:00:00 |
STRING | One-byte string of variable length | “(blank) |
WSTRING | Variable length double byte string | “(blank) |
CHAR | One-byte character | $00 |
WCHAR | Double byte character | $0000 |
BYTE | Bit sequence of length 8 | 16#00 |
WORD | Bit sequence of length 16 | 16#0000 |
DWORD | Bit sequence of length 32 | 16#0000_0000 |
LWORD | Bit sequence of length 64 | 16#0000_0000_0000_0000 |
Elementary types are used directly in variable declarations. Each variable takes the default value from the table above unless you initialize it:
VAR enabled : BOOL; // FALSE count : INT := 5; // explicit initial value ratio : LREAL; // 0.0 started : DT; // DT#1970-01-01-00:00:00END_VAR