Glossary
What is Data type?
The classification that fixes a variable size, value range and permitted operations: BOOL, INT, DINT, REAL, TIME and the rest.
The two commonest mistakes: using INT for an accumulating counter, which wraps negative at 32767 with no message, and comparing two REALs for equality when REAL is approximate.
Rule of thumb: REAL for every analogue measurement, DINT for anything that accumulates, INT for state machine steps, BOOL for anything on or off.
Related terms
- Type conversion
- Explicit functions that move a value between types, such as INT_TO_REAL, REAL_TO_INT, TRUNC and TIME_TO_DINT.
- Retained variable (RETAIN)
- A variable held in retentive memory, so it keeps its value through a power cut and restart.