68. How to do floating point calculations with integers?
To gain a result with decimal place when dividing integers, please convert the integer to float first.
Please see the following Macro. D8=5 is the integer value gained from PLC.
Line 10: Since D8 is an integer, D8/10 is performed as an integer operation and the result is 0. The result is then written to a float variable, float_D8, therefore float_D8 is 0.0.
Line 15: Since temp is a float, temp/10 is performed as a float operation and the result is 0.5.

No comments to display
No comments to display