Groovy web console

subscribe to the feed Subscribe
to this
site
RoundingError (via #groovywebconsole)
tweet this snippet Tweet
this
script

RoundingError

Published 2 months ago by olbo
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import java.math.BigDecimal

float f = 0.0
BigDecimal b = BigDecimal.ZERO

(1..10).each{
  f = f + 0.1
  b = b.add(0.1)
}

println "Float: "+ f
println "BigDecimal: "+ b