Jump to content

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

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

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

## Sign in

Already have an account? Sign in here.

Sign In Now
×

• Leaderboard
• #### Support

×
• Create New...

## Important Information

This site uses cookies. By clicking I accept, you agree to their use.