free quality report for PLCopenXML exports

Rules / real-to-word-mul

REAL_TO_WORD(x) * N: can the WORD overflow

A WORD holds 0..65535. If the product is larger, the high bits are lost and the register receives a wrapped value. The rule flags such places so the range can be checked.

Severity: Warning Rule id: real-to-word-mul REAL_TO_WORD(...)*N may overflow WORD

What the rule checks

WORD is limited to 0..65535, so make sure the product does not overflow.

What it does to the plant

An exchange register for SCADA or the HMI gets a small number instead of a large one: flow or energy on screen suddenly drops to near zero.

Example

Bad: the rule fires
PROGRAM ExchangeVAR    rFlow : REAL;    wFlowReg : WORD;END_VARwFlowReg := REAL_TO_WORD(rFlow) * 100;
Fixed: the rule is silent
PROGRAM ExchangeVAR    rFlow : REAL;    dwFlowReg : DWORD;END_VARdwFlowReg := REAL_TO_DWORD(rFlow * 100.0);

Both listings are run through the linter by an automated test: the rule fires on the first and stays silent on the second.

How to fix

  1. Check the range; if the product can exceed 65535, use DWORD or UDINT.
Check your project

Upload a PLCopen XML or CODESYS .export file: the report is free and the code is not stored.

Local version on GitHub →

The same linter without uploading a file: command line and GitHub Action.

Related rules

2026-11-26

Processing happens in memory, and the uploaded code is not stored. The tool advises; code changes are up to the engineer (see what the linter can't see). What happens to your code → · Rule reference · Your code & privacy · Industry benchmark · Feedback · GitHub