Floating point arithmetic is inexact
. You are dealing with periodic
fractions - even if think you don't - because your computer works in radix 2
and not in radix 10.
ever using floating point in whatever programming language read and understand http://en.wikipedia.org/wiki/Floating_point
Again, your problem has nothing to do with Java. To resolve your problem deal with integers only
, i.e. scale up everything by 100.