如何断言整数和浮点类型值在范围内

How to assert integer and float type values are within the bound

else if(KeyName=="amount")
    {
        log.info ("Result:" +actualvalue)
        assert actualvalue >=  lowerbound && actualvalue <=  upperbound
    } 

Result: 1009.750000

下界取0,上界=10010。

我正在打印所有值并在下面给出。

actualvalue; Sun Jul 02 07:19:36 IST 2017:INFO:1009.75000***0***10010

但条件不合格。
如何比较这两个值?
是因为类型不匹配吗?
如何解决?

给你:

def lBound = 0
def uBound = 10010
def actualValue = 1009.750000
assert lBound <= actualValue, 'actual value is less than lower bound'
assert uBound >= actualValue, 'actual value is greater than upper bound'

不确定您是如何申报的。即使是下面的代码片段也可以。

int lBound = 0
int uBound = 10010
float actualValue = 1009.750000
assert lBound <= actualValue && uBound >= actualValue