Download EV5000 User Manual

Transcript
Chapter 9 Macro
The configuration window is shown as follows:
Perform offline simulation and enter “5” and “2” in LW0 and Lw1 respectively, and press “=” to
obtain the result as follows:
According to our estimation, the result shall be 2.5 instead of 2. What is the problem? If the user is
familiar with the C language, he will be aware of the reason quickly. Because the data type for
LW0_R and LW1_R is “short”, according to the default type conversion principle of C language,
the division result will be rounded off to an integer. How to solve the problem? It is simple: just
convert an input value into the type of “double”:
LW2_W= (double)(LW0_R) / LW1_R;
294