# FLOAT COMPARE

## Recommended Posts

what am I doing wrong?  you can see that A>=B but the MB 10 is still 0. Is it possible that it because I'm comparing between MI to MF?  and how to do casting if its the case.

##### Share on other sites

• MVP 2023

You can't compare an MF to an MI.  I don't know why it let you enter that.  You'll have to convert the MI to an MF register.

Joe T.

##### Share on other sites

thanks! and how am I converting the MI to an MF register?

##### Share on other sites

• MVP 2023

I always tell people when they first start using PLC software to take the time to go through every menu and every sub-menu to get an idea of what's buried in there and where.  It's useful where you run into a question like this you can say "I thought I saw something like that..."

From ladder, look at Math -> Float -> Convert and you'll see the two blocks used for moving between floats and integers.  Go into the Help and search for "float convert" and you'll see much better usage diagrams than I can go into here.

What you're running into is how much of the pain in the butt it is to use floating point in a PLC.  Everybody thinks they need it if there are decimals involved.  You can get precision more elegantly with integers (especially longs) if you embrace the concept of a "virtual decimal point".  Every number is 10, 100, 1000 times larger to accommodate the precision on the other side of the decimal and you just keep track of it.  It's an easier technique you pick up with experience.

Joe T.

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×
×