| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public Item item(final QueryContext qc, final InputInfo ii) throws QueryException { |
| 59 | final Item item = expr.atomItem(qc, info); |
| 60 | if(item == Empty.VALUE) return Empty.VALUE; |
| 61 | |
| 62 | final Type type = item.type; |
| 63 | if(type.isUntyped()) { |
| 64 | final double d = item.dbl(info); |
| 65 | return Dbl.get(minus ? -d : d); |
| 66 | } |
| 67 | if(!type.isNumber()) throw numberError(this, item); |
| 68 | |
| 69 | if(!minus) return item; |
| 70 | if(type == BasicType.DOUBLE) return Dbl.get(-item.dbl(info)); |
| 71 | if(type == BasicType.FLOAT) return Flt.get(-item.flt(info)); |
| 72 | if(type == BasicType.DECIMAL) return Dec.get(item.dec(info).negate()); |
| 73 | // default: integer |
| 74 | final long l = item.itr(info); |
| 75 | if(l == Long.MIN_VALUE) throw RANGE_X.get(info, item); |
| 76 | return Itr.get(-l); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public Expr copy(final CompileContext cc, final IntObjectMap<Var> vm) { |