Created
July 22, 2015 18:37
-
-
Save schmitch/f23e59d85c9fd84a347d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import scala.math.BigDecimal.RoundingMode | |
| object Demo extends App { | |
| val d: Double = 1.0 / 3 * 3 + 0.01 | |
| val bd1 = BigDecimal(1.0) / BigDecimal(3) * BigDecimal(3) + BigDecimal(0.01) | |
| println("d: " + d) | |
| println("bd1: " + bd1.setScale(2, RoundingMode.HALF_DOWN)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment