Can't add 0.0x to an real variable with no larger than 1048576 ?????

TiakTiak
2018-10-03
2018-10-08
  • TiakTiak - 2018-10-03

    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;

     
  • 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.

     

Log in to post a comment.