Solved
Forum Discussion
rupert_anderson
11 years agoValued Contributor
Hi,
Think this is more of a Groovy question than a SoapUI question, but assuming your value can be represented as a double then you can do something like:
For 2 decimal places:
def result=2.5064267352
log.info new Double(result).round(2) //2.51
assert new Double(result).round(2)==2.51 //OK
For 3 decimal places:
log.info new Double(result).round(3) //2.506
assert new Double(result).round(3)==2.506 //OK
If by 'to (3)' you mean 2.506... rounded to 3, then new Double(result).round(0) will give you 3.0, new Double(result).round() will give you 3
Hope this helps,
Cheers,
Rupert