+4  A: 

That is an artifact from how floating point numbers are stored.

Either you could round the answer sprintf("%.3f", result) or use some Decimal handling package.

Jonas Elfström
+2  A: 

I suggest you do a search on the web for "floating point accuracy" or look at the absolute dozens of other questions on SO that yours is a duplicate of.

paxdiablo
Unfortunately those aren't the terms a newbie will search on (even if they bother).
dmckee
+2  A: 

have you seen this

Adinochestva
+3  A: 

It is normal with floating point arithmetic. You can change the way how your floats and doubles are printed using %.3g for example

dfa
+2  A: 

You can't fix this. Not all numbers can be represented as floats, see "how is floating point stored, when does it matter".

Ralph Rickenbach
Hey! Just the other day I was asking if anyone could remember the earliest incarnation of this topic.
dmckee
+4  A: 

Take a look at this - it should tell you everything you need to know about Why Computers Suck At Math

Alan
Was going to answer with the same article, however you beat me to it! A must read though!
Rekreativc
+4  A: 

The problem is because the .575 value doesn't have an exact representation in floating point encoding. The fix depends on what you have to do with the value as well as the impact of the inaccuracy.

If it is just a display problem use rounding to 3 decimals and you'll get the 0.575.

If it is because of computation inaccuracy, try keeping the value as a fraction which will be exact. You'll have to store and handle two floating point values but it will be exact. Postpone the effective division to the last moment when you need the result.

Check if the difference between the two value is relevant for your problem. For instance subtract sqrt epsilon to the value and check how much the change influences the final computation result and compare it with the required or desired precision.

Unfortunately we have to live with the limitation of real value representation in float. Using 128 bit precision floats will make the error much smaller but not null.

chmike