given the following line
BigDecimal step = 10.0G**-1.0G
groovy 1.7.5 returns incorrect
0.1000000000000000055511151231257827021181583404541015625
and groovy 1.8 returns the correct
0.1
Unfortunately, I want to solve my problem in Grails. 1.4 with groovy 1.8 is not yet stable enough (controllers are not updated in dev mode), and grails 1.3.7 comes with groovy 1.7.x
two questions:
Am I doing something wrong or is this a bug in 1.7.5?
How can I avoid this behavior? I, although BigDecimals, where is ideal for this kind of rounding problem?
second update: (forget about the first update) -
Now I'm a little confused. It seems that I get different results every time I try ....:
BigDecimal step = 10.0G**-1.0G
println step
returns 0.1000000000000000055511151231257827021181583404541015625
and
println 10.0G**-1.0G
returns
0.1
in both versions of groovy.
BigDec step = 10.0G**-1.0G groovyConsole , groovy. , - groovyConsole.
toString, .
, ...
def step = 10.0G**-1.0G
Double...
, :
Thanx