BOOL, INT, DINT, REAL: choosing the right type
Picking a type is a decision about range, memory and precision, and getting it wrong shows up as an overflow nobody sees.
Short answer
The four that cover most work are BOOL for a single bit, INT for whole numbers from -32,768 to 32,767, DINT for a 32-bit integer up to about 2.1 billion, and REAL for a 32-bit floating point value. The common failure is INT overflow, which wraps silently to a negative number with no error and no warning.
Four types cover most industrial work, and the choice between them is about range, memory and precision.
The four
- BOOL: one bit. On or off.
- INT: 16 bits, -32,768 to 32,767.
- DINT: 32 bits, roughly plus or minus 2.1 billion.
- REAL: 32 bits of floating point, about seven significant digits.
The failure that costs the most
INT overflow. Multiply 1,000 by 100 in INTs and the answer is not 100,000; it is a negative number, arrived at silently.
This bites in scaling code, in totalisers, and in anything counting parts over a shift. The fix is to use a DINT for the destination and for the intermediate, not only the final result.
If a value can grow over time, it is a DINT. Shift totals, motor hours, part counts.
REAL is not a safe default
Floating point cannot represent 0.1 exactly. Two REALs that should be equal frequently are not, which makes equality comparisons unreliable, and repeated addition accumulates error.
Use REAL where you are representing a measured physical quantity. Use integers where you are counting.
Common questions
- What happens when an INT overflows in a PLC?
- It wraps. Adding one to 32,767 gives -32,768, silently, with no fault and no indication. Any calculation whose intermediate result can exceed 32,767 needs a DINT for the destination, and often for the intermediate as well.
- Should I use REAL for everything to be safe?
- No. REAL cannot represent most decimal values exactly, so equality comparisons are unreliable and repeated arithmetic accumulates error. Use integers for counting and REAL for measured quantities and calculations that genuinely need fractions.
Keep reading
- Safety
SIL or PL: which one does your machine need?
Two standards, two scales, and one machine. Which one applies, how they map to each other, and why the answer is usually ISO 13849.
- Safety
Categories B, 1, 2, 3 and 4, in plain terms
Five architectures, what a single fault does to each, and the practical wiring that goes with them.
- Safety
Safety relay or safety PLC: how to decide
One is a wiring decision, the other is a programming one. The count of safety functions, not the size of the machine, is what settles it.