I have a simple add function that can't add 0,048 to a real variable if the real value is higher than 1048576.
I can add 1.0 to 1048576 and 0.1 to 104857 but not 0.01 to 1048576.
Does anyone have any ideas what is going on why it stops at 1048576 ??
CountTrig(CLK:=Enable );
IF CountTrig.Q
THEN Result:=Result+ValueAdd;
END_IF;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2018-10-08
Originally created by: scott_cunningham
I think you are basically at the precision limit of a real (32 bit float). With a number such as a million, there will be digitization and round off errors. If you search the internet you will find some examples. Here is one that claims at 1000000 the resolution steps are only 0.0625. https://stackoverflow.com/questions/168 ... imitations
I donβt always believe what I read, but in this case it is intuitive. If you need the accuracy, you need to switch to an LREAl, if your platform supports it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a simple add function that can't add 0,048 to a real variable if the real value is higher than 1048576.
I can add 1.0 to 1048576 and 0.1 to 104857 but not 0.01 to 1048576.
Does anyone have any ideas what is going on why it stops at 1048576 ??
CountTrig(CLK:=Enable );
IF CountTrig.Q
THEN Result:=Result+ValueAdd;
END_IF;
Originally created by: scott_cunningham
I think you are basically at the precision limit of a real (32 bit float). With a number such as a million, there will be digitization and round off errors. If you search the internet you will find some examples. Here is one that claims at 1000000 the resolution steps are only 0.0625. https://stackoverflow.com/questions/168 ... imitations
I donβt always believe what I read, but in this case it is intuitive. If you need the accuracy, you need to switch to an LREAl, if your platform supports it.