Search This Blog

_____________________________________________________________

Join Our Site To Subscribe

Wednesday, July 27, 2011

About floating-point calculations and the emulator

There are instruction differences across programming languages as well as across Logix platforms. The following examples use the operation "i = n / m" where all the operands are integers. Ladder DIV instructions perform an integer divide operation and store the immediate result in the destination. For "n" = 800 and "m" = 1000, "i" is equal to 0. The DIV function block instructions perform only floating point operations. The function block instruction converts the inputs to reals (if necessary) and then converts the result from a real to the destination type is (if necessary). In this example, "n" is converted to 800.0 and "m" is converted to 1000.0. The result of the operation is 0.8. That result then gets converted to an integer where rounding rules apply and the final destination value is 1. This difference between ladder and function block instructions applies to all Logix platforms. Function block instructions only perform floating point operations. 

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...