Plex displays a double as 12, but assigns it to an integer as 11

Document ID : KB000123734
Last Modified Date : 26/12/2018
Show Technical Document Details
Issue:
In a WINC client we multiplied a double of 0.0012 by 10000, and this displays in a double as 12, but if we try and assign this to an integer, it assigns 11 to the integer. This has been tried on Plex 7.1 and 7.2.1. We would like the value that is displayed in messages and on the panel as being in the double to also be the value stored in the integer. 
If we cast the value from the double to the integer it does put the 12 into the integer. 
I plan on attaching a model with the sample function "DoubleToFloatTest". Implementation name "DblToFlt". 

This appears to also be a problem for 0.0003, 0.0006, 0.0012, 0.0024, 0.0029, 0.0048, 0.0058, 0.0093, 0.0096, 0.0113, 0.0116, 0.0163, 0.0169, 0.0355, 0.0372, 0.1473, 0.1478, 0.1483, 0.1488, and 0.1493.
Resolution:
We have recreated the reported scenarios and there is data loss in Double to Integer type conversion. This seems quite obvious considering how C/C++ run-time handles floating point numbers internally. 
Verified outside of Plex, like MS Visual Studio & Linux GCC – the result is same as Plex shows. 

For example, double value 12.000000 is being represented as 11.999999999999998 internally and type conversion from double to integer gets value 11, and this goes similar for the set of values you have mentioned in the case. 

So with this, Plex C++ runtime is behaving the way the floating point represented within the system C++ run-time environment – so making any changes towards this behavior will lead into unforeseen impact. 

As a workaround, making this type conversion (double to integer, in this case) - better use Plex AD Cast statement to achieve the desired results.