Floating point precision is a problem that we always have to work with when it comes to computers. My advice for this problem is to think of the currency as cents rather than dollars. In other words, internally to your solution multiply everything by 100
so you can work with integers.