在Groovy中,你可以使用BigDecimal类来处理小数点后面的数值,并将其作为返回值返回。以下是一个示例代码:

def getDecimalValue() {
    def decimalValue = new BigDecimal("3.14")
    return decimalValue
}

def result = getDecimalValue()
println result // 输出 3.14

在上面的代码中,我们使用BigDecimal类来创建一个包含小数点后面数值的对象decimalValue,然后将其作为返回值返回。在调用getDecimalValue()函数时,将返回的结果存储在result变量中,并打印出来。输出结果为3.14

groovy return函数怎么把小数点后面的也 return回去

原文地址: http://www.cveoy.top/t/topic/iHux 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录