Jump to content

Data Real Inaccurate


Recommended Posts


I've a routinewhitch add 0.1 every 100ms to variable  counter(Real).  And every time machine is idle it is reset to 0.

When running this the counter value is not correct, it is 1.1001 9.9999 , but adding 0.1  and no other value this shouldn;t be possible. 


Now i add every 100ms a 1 to an integer, then convert it to real, then multiply *0,1, and this works,


Link to comment
Share on other sites

Thanks for you answer,

I would like to know more,

I haven't seen this in for instance Omron or Siemens. Why is this happening?

In general if I want to use a calculation where the output is being used and linked at the input, i cannot use this?

What if we use Real on a measured value, what is max rounding error then? 

Link to comment
Share on other sites

  • MVP 2023

There is no reason to use floating point numbers in this situation. No digital computer or PLC can handle floating point numbers perfectly and it's best to avoid them when possible. This is due to the conversion from decimal to binary and then back to decimal. Without infinite precision, which is of course impossible, there will be rounding errors which can be significant.

In your case, use integers (add 1, not 0.1) and display the number with one decimal place. If you need to perform calculations, just keep track of where the decimal place is and make sure it matches on all the other numbers in the calculation.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...