I've an issue where I don't know where it comes from.
I'm trying to make a combination of two numbers:
-First Number I will call A:
where he could gets until 5 digits.aaaaa => Actual type UDINT
-Second number i will call B:
where he could gets also until 5 digits.bbbbb => Actual type UDINT
A:28
b:235
How I do is :
REAL_TO_UDINT(((UDINT_TO_REAL(28)/10000)+235)*10000)
My Problem is when b as 3 digits my result is ok.
Result : 23500028
but now if my b numbers increase lets said 4 or 5 digits the result change
and I arrive to:
b:1235
result: 123500030
I think there is a rounding somewhere That I don't find.
But in anycase my result is still under what UDINT can accept, this is why I don't understand
thanks you for your comment
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello ,
I've an issue where I don't know where it comes from.
I'm trying to make a combination of two numbers:
-First Number I will call A:
where he could gets until 5 digits.aaaaa => Actual type UDINT
-Second number i will call B:
where he could gets also until 5 digits.bbbbb => Actual type UDINT
A:28
b:235
How I do is :
REAL_TO_UDINT(((UDINT_TO_REAL(28)/10000)+235)*10000)
My Problem is when b as 3 digits my result is ok.
Result : 23500028
but now if my b numbers increase lets said 4 or 5 digits the result change
and I arrive to:
b:1235
result: 123500030
I think there is a rounding somewhere That I don't find.
But in anycase my result is still under what UDINT can accept, this is why I don't understand
thanks you for your comment
The REAL format is limited to about 7 or 8 digits of precision.
For the precision you need, use LREAL.