Division not giving the same value as multiplication

Hi Everyone,

In some of our modbus landing modules we are using DIV blocks to convert floating point values to 16-bit UINT. In other modules, we are using MLTY.

I noticed that they do not give the same results, see 16-bit UINT OUT parameters on screenshot below:

It seems that MLTY works better, but I need to explain to the customer why we should change from (x / 0.001) to (x * 1000). Any ideas?

As you see, the result is the same also with CALC blocks: division gives an incorrect result.

Istvan

4 Replies

  • Floating point precision is always going to be greater than integers, therefore, dividing a floating point number by another will give you a fraction (then rounded by DeltaV data type conversion), whereas using floating point and multiplication with integers will result in an integer.

    Implying decimal places by converting to integers, I would always use multiply.
  • In reply to AdrianOffield:

    Or the machine is a really, really old Pentium processor machine that had this problem [;)]

    Niklas Flykt 

    Klinkmann Oy

    Key Account Manager safety products

    nikfly@gmail.com

  • In reply to Niklas Flykt:

    Nope, this is an SX controller flashed to v12.3.1 :)
    Adrian, the thing that caught my eye is that the output of the MLTY and the DIV blocks look to be the same (and correct). Only the conversion distorts the value.
  • In reply to István Orbán:

    True, but the OUT parameter is floating point so it is showing you a FP representation. Try performing the division in a calc block and writing to the UINT instead of wiring the OUT to the UINT parameter.