If you want to control the precision, never use floats or doubles, only the BigDecimal class (in Java) or as I saw in real applications using currencies, convert everything to long for your computations and use floats or doubles only for the display (by dividing the integer value).