Rockwell Automation Publication 1756-RM003N-EN-P - October 2011 647
Common Attributes Appendix A
Floating Point Values
Logix controllers handle floating point values according to the IEEE 754
standard for binary floating-point arithmetic. This standard defines how floating
point numbers are stored and calculated. The IEEE 754 standard for floating
point math was designed to provide speed and the ability to handle very large
numbers in a reasonable amount of storage space.
Not all decimal values can be represented in binary format to the exact value,
which results in a loss of precision. This standard is widely used throughout
industry, including in computer operating systems. As a result, there is no way to
control the number of digits to the right of the decimal point in logic in a
Logix5000 controller.
For example, in most cases, if you subtract 10 from 10.1, you expect the result to
be 0.1. In a Logix controller, the result could very well be 0.10000038. In this
example, the difference between 0.1 and 0.10000038 is .000038%, or practically
zero. For most operations, this small inaccuracy is insignificant. To put things in
perspective, if you were sending a floating point value to an analog output
module, there would be no difference in the output voltage for a value being sent
to the module that differs by .000038%. Again, this applies to most cases, but not
necessarily every time.
Guidelines for Floating-point Math Operations
Follow these guidelines:
• When performing certain floating-point math operations, there may be a
loss of precision and you may receive unexpected results. In general,
floating-point numbers are quite accurate, but floating-point processors
have their own internal precision that can impact resultant values.
• Do not use floating point math for money values or for totalizer functions.
Use INT or DINT values, scale the values up, and keep track of the
decimal place (or use one INT or DINT value for dollars, and a second
INT or DINT value for cents).
• Do not compare floating-point numbers. Instead, check for values within a
range. The LIM instruction is provided specifically for this purpose.