it's simple: floating point represented in finite binary is not precise for all values. learn to live with it. it's one of the first things they teach you in comp sci. unless you really know what you're doing it is not a subject that you re-invent as a weekend project, not unless you're a fan of dire, unforeseen consequences.