marcinmrag Posted January 16, 2018 Report Posted January 16, 2018 Hello ! how can I round up the real value to 2 decimal places? I have value of angle from Robot and I would like to have a confirmation of position. But Is a lot of decimal places and It take a long time when two value get equel.
Michael Walsh Posted January 19, 2018 Report Posted January 19, 2018 I would multiply it by 100 as a floating point number and then use the ROUND instruction. This will convert it to a LINT or DINT and then just compare it to a LINT / DINT. 3.14159 x 100 = 314.159 Using ROUND becomes 314. Then use an = instruction to compare it to LINT#314.
IO_Rack Posted January 19, 2018 Report Posted January 19, 2018 On 1/16/2018 at 11:39 AM, marcinmrag said: But Is a lot of decimal places and It take a long time when two value get equel. For this reason, there is a fundamental reason not to use "= x" comparison to a REAL value. If you need the precision then do as Michael says. Typically I will perform "<= x", ">= x" or compare a window ">= x && < y".
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now