, - , , , .
:
groovy:000> "123.0001".toBigDecimal()
===> 123.0001
groovy:000> "123.0001".toDouble()
===> 123.0001
groovy:000> new BigDecimal("123.0001".toDouble())
===> 123.000100000000003319655661471188068389892578125
, double, double BigDecimal. BigDecimal , , toString .
, . , , , , toString double, Decimal, , toString double, :
groovy:000> d = "123.0001".toDouble()
===> 123.0001
groovy:000> d.toString()
===> 123.0001
groovy:000> new BigDecimal(d.toString())
===> 123.0001
BigDecimal, , -
groovy:000> d = 123.0001
===> 123.0001
groovy:000> s = d.toString()
===> 123.0001
groovy:000> s.substring(s.indexOf('.')).length() - 1
===> 4
.
, - , groovy. ( , , , , , , , 0)
def getPlaces(d) {
s = d.toString()
s.substring(s.indexOf(".")).length() - 1
}