Skip to content

Instantly share code, notes, and snippets.

@schmitch
Created July 22, 2015 18:37
Show Gist options
  • Select an option

  • Save schmitch/f23e59d85c9fd84a347d to your computer and use it in GitHub Desktop.

Select an option

Save schmitch/f23e59d85c9fd84a347d to your computer and use it in GitHub Desktop.
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