Thread Content
How can I convert dint to int in PCS7? Is there a module for direct conversion?
I can't remember if there is a module for converting DINT to INT in PCS7. But such a switch is risky. The range of double integer is 0~4294967295 (regardless of positive and negative), while the range of integer is 0~65535. If your double integer is greater than 65535 (regardless of whether it is positive or negative), the value you convert will be wrong. If you are sure that the value of the double integer is between 0 and 65535, then you can take out the high-order word of the double integer and make it an integer. Note that it is not a low-order word
First of all, thank you very much for your friend's reply, and also thank you very much for the reminder from the buddy on the second floor. I spent a lot of effort yesterday and found a module from DINT to INT. It is very easy to use. My double integer value should be between 0 and 65535, so I used it like this for the time being. No problems have been found for the time being. Your reminder has made me understand a lot, thank you!
Ha, you're welcome. Just help each other and learn from each other * , we can improve together :)
If you use SCL language, there is a function called DINT_TO_INT can be converted, and SCL's type conversion functions are very comprehensive and rich, basically everything you want to use is available. LAD and CFC can only be checked to see if they are in the library, but they have not been used.