Java/Scala: Why you shouldn’t use double or float values for currency

Here are a couple of examples about why you shouldn’t use double or float values for currency, courtesy of Joshua Bloch’s Effective Java book:

scala> 1.03 - .42
val res0: Double = 0.6100000000000001

scala> 1.00 - 9 * 0.10
val res1: Double = 0.09999999999999998