UINT
Quick answer
UINT is a 16-bit unsigned PLC integer with the IEC range 0 to 65,535. It is intended for non-negative arithmetic; WORD has the same width but represents a bit string.
Key Takeaways
- UINT is a 16-bit unsigned PLC integer with the IEC range 0 to 65,535. It is intended for non-negative arithmetic; WORD h...
- Beginner-level topic in Data Types & Variables
- Commonly used in: Unsigned 16-bit registers and protocol fields, Non-negative indexes and counts
- Related to: INT, USINT, UDINT
Detailed Definition
UINT stores a non-negative whole number in 16 bits. It is appropriate for an unsigned register, index or count that must support arithmetic. WORD also contains 16 bits, but IEC-style systems classify WORD as a bit string for masks and packed flags rather than as an arithmetic integer.
A UINT cannot represent a negative result. Decrementing zero, mixing signed and unsigned operands, or narrowing a larger value can produce a platform-specific compile-time error, diagnostic, truncation or wrap. Guard the operation or use a wider signed intermediate when a negative result is meaningful.
Technical reference
The IEC range is stable; unsigned support on older controllers and out-of-range behavior must be checked.
Reviewed against current primary documentation:
UINT PLC Data Type at a glance
- Type family
- Unsigned integer
- Width
- 16 bits (2 bytes)
- Signedness
- Unsigned
- Range / values
- 0 to 65,535
- IEC-style literal
- UINT#502
- Best fit
- Non-negative 16-bit arithmetic and explicitly unsigned fields
Avoid this type when: A calculation can be negative or exceed 65,535.
Vendor notation and support boundaries
IEC names help portability, but controller generations, compiler options and instruction signatures still differ.
CODESYS / TwinCAT
The IEC-style type and TYPE#literal form are available. The compiler can reject an out-of-range typed literal, but runtime arithmetic still needs boundary testing.
Siemens SIMATIC
S7-1200 documentation lists the IEC signed and unsigned integer widths used here. Confirm instruction support and conversion behavior for the exact CPU and TIA Portal version.
Rockwell Logix
Current documentation lists unsigned types on 5380/5580-class and newer controllers, while 5370/5570-class controllers list the signed integer family only. Check the controller family before choosing a portable tag type.
IEC-style Structured Text
Prevent unsigned underflow
VAR
Remaining : UINT := UINT#10;
END_VAR
IF Remaining > UINT#0 THEN
Remaining := Remaining - UINT#1;
END_IF;The zero guard keeps the mathematical result within UINT range. A production sequence should also define what happens when a decrement is requested at zero.
Boundary cases to test
These are mathematical boundaries, not promises about one runtime's failure mode.
| Input / operation | Mathematical result | Safe engineering action |
|---|---|---|
| 65,535 + 1 | 65,536, which is outside UINT range. | Promote to UDINT or guard the upper boundary before assignment. |
| 0 − 1 | −1, which UINT cannot represent. | Prevent the decrement or use a signed intermediate and validate the final value. |
Conversion guidance
- Use UDINT for an intermediate that can exceed 65,535.
- Use DINT when subtraction can legitimately produce a negative value.
- Range-check DINT or UDINT before converting to UINT.
- Do not treat WORD and UINT as interchangeable without an explicit, documented interpretation.
Before using this type
- 1Test 0, 1, 65,534 and 65,535.
- 2Test every signed/unsigned interface with a high-bit value.
- 3Confirm UINT support on the target controller generation.
- 4Monitor diagnostics while deliberately exercising both boundaries.
Primary technical sources
These sources support the type ranges and platform notes above. The project's controller, firmware and compiler documentation remains authoritative for execution.
- Integer data types
CODESYS Development System — Published ranges, widths and warning about information loss in narrowing conversions.
- PLC variable naming and type families
CODESYS Development System — Distinguishes arithmetic integer types from WORD-family bit strings.
- Typed literals
Beckhoff Automation — Documents TYPE#literal notation and compile-time loss checks in TwinCAT.
- Studio 5000 elementary data types
Rockwell Automation — Ranges, conversion behavior and controller-family support in current Logix documentation.
Common Questions
What is UINT?
UINT is a 16-bit unsigned PLC integer with the IEC range 0 to 65,535. It is intended for non-negative arithmetic; WORD has the same width but represents a bit string.
When should I use UINT?
UINT is particularly useful in scenarios such as Unsigned 16-bit registers and protocol fields and Non-negative indexes and counts. Consider implementing it when you need reliable, efficient solutions for these types of applications.
What should I verify before using UINT?
Test 0, 1, 65,534 and 65,535. Test every signed/unsigned interface with a high-bit value. Confirm UINT support on the target controller generation. Monitor diagnostics while deliberately exercising both boundaries.
What are related concepts I should learn?
To fully understand UINT, you should also familiarize yourself with INT, USINT, and UDINT. These concepts work together in industrial automation systems.
Continue Learning
Ready to deepen your understanding of UINT? Here are some recommended resources:
Was this helpful?
Let us know if this glossary term helped you understand UINT better.
Your feedback helps us improve our glossary and create better content for the PLC programming community.
Quick Info
- Category
- Data Types & Variables
- Difficulty
- Beginner
- Tier
- Important
About Data Types & Variables
Data structures, variable types, and memory organization