PLC Data Types and Ranges
The size and range of the data types you meet in PLC programming, and the overflow traps to watch for.
Integer and bit types
| Type | Size | Range |
|---|---|---|
| BOOL | 1 bit | 0 or 1 (FALSE or TRUE) |
| SINT | 8 bit | −128 to 127 |
| USINT / BYTE | 8 bit | 0 to 255 |
| INT | 16 bit | −32,768 to 32,767 |
| UINT / WORD | 16 bit | 0 to 65,535 |
| DINT | 32 bit | −2,147,483,648 to 2,147,483,647 |
| UDINT / DWORD | 32 bit | 0 to 4,294,967,295 |
| LINT | 64 bit | −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
Floating-point types
| Type | Size | Range (approx.) | Precision |
|---|---|---|---|
| REAL | 32 bit | ±1.18×10−38 to ±3.40×1038 | About 7 decimal digits |
| LREAL | 64 bit | ±2.23×10−308 to ±1.80×10308 | About 15-16 decimal digits |
Traps to watch for
- 16-bit overflow in scaling. Multiplying a raw count of 32,000 by 100 in an INT overflows. Convert to REAL or DINT before multiplying.
- REAL loses integers above about 16.7 million. A running total or counter kept in a REAL stops counting up correctly once it gets that large. Use DINT or LINT for counters and accumulators.
- Integer division truncates. 7 / 2 gives 3 in an integer instruction. Do the division in REAL if you need the fraction.
- Comparing REALs for equality. Floating-point results carry tiny errors, so compare with a tolerance rather than testing for exact equality.
- Signed versus unsigned. A 16-bit register holding 40,000 reads as −25,536 when interpreted as a signed INT. Many Modbus and analog values need the unsigned reading.
Type names and which types are available differ between platforms, and some platforms lack unsigned types or 64-bit types. Check the manual for the PLC you are using. The data converter shows how one register reads as signed, unsigned, hex and BCD.
Reference summary based on IEC 61131-3 and IEEE 754. Verify against your PLC platform's documentation.