Tag Clamping and Float Conversion

Hi, I am currently encountering an issue using the clamping feature on tags.

I have a tag that is clamped between [0-4.4]. Currently if the REAL value in the PLC is set to [4.4], the conversion results in the value being [4.400000095] in Ignition. Since [4.400000095 > 4.4] the value is considered out of the limits.

I do not want to increase the upper clamp limit, since 4.4 is truly the maximum the user should be able to enter.

Is there any method to clamp the number after it has been formatted? Or are there other potential solutions?

This isn't a formatting issue, it's a floating point accuracy issue.

4.4 doesn't have an exact representation in IEEE-754 floating point - the closest actual value is 4.400000095367431640625.

You will never get a value that is actually 4.4 in its representation, you would only see 4.4 after formatting/rounding.

1 Like

Thank you for the fast response.

Apologies on my poor phrasing of the question. I did determine that the value in Ignition is correct in terms of its IEEE-754 representation. I was optimistic in thinking that there may be a method to clamp the value after it is formatted.

Would you say the only solution would be to increase the upper limit by an amount that is less than the formatting? For example, if I format the number to two decimal places (#,##0.00) then I need set the upper limit to 4.401.

I played with this a little and the only thing that makes it work like you want is using a double precision value in the OPC/PLC source instead of single precision.

Otherwise you'll have to play with increasing the eng limits. All the clamping/scaling/etc is pre-format.

Okay, I appreciate you taking the time to look into this issue.

I will continue forward with increasing the limits slightly. Thanks!