You didn't mention where your data comes from. One problem is that as soon as you import data as floating point, it is stored in an internal format that loses precision if it cannot be represented precisely as n/2^m (edited). Whatever the conversion, do it as early as possible, as the first thing you do with your data before any other mathematical operation.
MJD suggests in his blog about Moonpig: a billing system that doesn't suck that because floating-point numbers are among the things that suck, the law of the Moonpig project states that "...all money amounts are integers. Each money amount is an integral number of “millicents”..."
The blog's discussion of handling of financial numbers is very helpful. Please do read it. I don't think I would touch financial data again without first browsing through it to refresh my memory.