I have an expression in a structured text routine of a Logix controller that looks more or less like the following:
As you might infer, all of the variables are DINT data types. The value of the complete calculation will always be a number in the thousands, and decimal accuracy is not important, so I have no problem with the final answer being truncated, rounded, or whatever else a PLC might conceivably do with a non-integer.
What I'm concerned about is that Integer5 will always be larger than Integer4, meaning that the first part of the calculation to be executed - Integer4 / Integer5 - will always result in a number less than 1. If the PLC truncates that (or rounds it, for that matter) before performing the rest of the multiplication steps, my result will invariably be zero. However, if the PLC performs the calculation as a floating point and just truncates/rounds it at the end, everything will work as intended.
Can anyone point me to the relevant section of documentation to understand how calculations like this will be performed?
Code:
ResultInteger := Integer1 * Integer 2 * Integer 3 / (Integer4 / Integer5);
What I'm concerned about is that Integer5 will always be larger than Integer4, meaning that the first part of the calculation to be executed - Integer4 / Integer5 - will always result in a number less than 1. If the PLC truncates that (or rounds it, for that matter) before performing the rest of the multiplication steps, my result will invariably be zero. However, if the PLC performs the calculation as a floating point and just truncates/rounds it at the end, everything will work as intended.
Can anyone point me to the relevant section of documentation to understand how calculations like this will be performed?