Rounds values. @param qc query context @param mode rounding mode @return number or Empty#VALUE @throws QueryException query exception
(final QueryContext qc, final RoundMode mode)
| 44 | * @throws QueryException query exception |
| 45 | */ |
| 46 | final Item round(final QueryContext qc, final RoundMode mode) throws QueryException { |
| 47 | final ANum value = toNumberOrNull(arg(0), qc); |
| 48 | final Item precision = arg(1).atomItem(qc, info); |
| 49 | |
| 50 | final int scale = precision.isEmpty() ? 0 : (int) Math.max(-1 << 20, |
| 51 | Math.min(1 << 20, toLong(precision))); |
| 52 | return value == null ? Empty.VALUE : value.round(scale, mode); |
| 53 | } |
| 54 | } |