Examples of NumericValue


Examples of net.sf.saxon.value.NumericValue

     * Evaluate the expression.
     */

    public Item evaluateItem(XPathContext context) throws XPathException {

        NumericValue v1 = (NumericValue) operand.evaluateItem(context);
        if (v1 == null) {
            return backwardsCompatible ? DoubleValue.NaN : null;
        }
        return v1.negate();
    }
View Full Code Here

Examples of net.sf.saxon.value.NumericValue

    public Item evaluateItem(XPathContext context) throws XPathException {

        AtomicValue val0 = (AtomicValue)argument[0].evaluateItem(context);
        if (val0==null) return null;
        NumericValue val = (NumericValue)val0;

        switch (operation) {
            case FLOOR:
                return val.floor();
            case CEILING:
                return val.ceiling();
            case ROUND:
                return val.round();
            case HALF_EVEN:
                int scale = 0;
                if (argument.length==2) {
                    AtomicValue scaleVal0 = (AtomicValue)argument[1].evaluateItem(context);
                    NumericValue scaleVal = (NumericValue)scaleVal0;
                    scale = (int)scaleVal.longValue();
                }
                return val.roundHalfToEven(scale);
            case ABS:
                double sign = val.signum();
                if (sign < 0) {
View Full Code Here

Examples of org.apache.drill.exec.ref.values.NumericValue

     
      for(int i =0; i < args.length; i++){
        final DataValue v = args[i].eval();
//        logger.debug("DataValue {}", v);
        if(Types.isNumericType(v.getDataType())){
          NumericValue n = v.getAsNumeric();
          NumericType nt = n.getNumericType();
//          logger.debug("Numeric Type: {}", nt);
          if(isFloating || nt == NumericType.FLOAT || nt == NumericType.DOUBLE){
            if(!isFloating){
              d = l;
              isFloating = true;
            }
            d *= n.getAsDouble();
          }else{
            l *= n.getAsLong();
          }
         
        }else{
          throw new RecordException(String.format("Unable to multiply a value of  %s.", v), null);
        }
      }
     
      NumericValue out = null;
      if(isFloating){
        out = new ScalarValues.DoubleScalar(d);
      }else{
        out = new ScalarValues.LongScalar(l);
      }
View Full Code Here

Examples of org.apache.drill.exec.ref.values.NumericValue

  }

  @Override
  public void addRecord() {
    DataValue dv = child.eval();
    NumericValue v = dv.getAsNumeric();
    if (integer) {
     
      switch (v.getNumericType()) {
      case DOUBLE:
      case FLOAT:
        integer = false;
        d = l; // loss of precision
        d += v.getAsDouble();
        break;
      case INT:
      case LONG:
        l += v.getAsLong();
        return;
      default:
        throw new UnsupportedOperationException();
      }
    }else{
      switch (v.getNumericType()) {
      case DOUBLE:
      case FLOAT:
      case INT:
      case LONG:
        integer = false;
        d += v.getAsDouble();
        return;
      default:
        throw new UnsupportedOperationException();
      }
     
View Full Code Here

Examples of org.exist.xquery.value.NumericValue

        if (getSignature().getArgumentCount() > 1) {
          precision = (IntegerValue) getArgument(1).eval(contextSequence, contextItem).itemAt(0).convertTo(Type.INTEGER);
        }
           
          final Item item = seq.itemAt(0);
          NumericValue value;
          if (item instanceof NumericValue) {
        value = (NumericValue) item;
      } else {
        value = (NumericValue) item.convertTo(Type.NUMBER);
      }
         
      result = value.round(precision);
        }
       
        if (context.getProfiler().isEnabled())
            {context.getProfiler().end(this, "", result);}
       
View Full Code Here

Examples of org.gdbms.engine.values.NumericValue

        } else if (f.getDriverType().equals(DECIMAL)
                || f.getDriverType().equals(NUMERIC)) {
            int scale = Integer.parseInt(f.getParams().get(SCALE));
            int precision = Integer.parseInt(f.getParams().get(PRECISION));
           
            NumericValue nv = (NumericValue) value;
            if (scale < nv.getDecimalDigitsCount()) {
                return "too many decimal digits";
            }
            if (nv.getDecimalDigitsCount() > 0) {
                /*
                 * Don't count the decimal point: length() - 1
                 */
                if (Double.toString(nv.doubleValue()).length() - 1 > precision) {
                    return "too long";
                }
            } else {
                if (Long.toString(nv.longValue()).length() > precision) {
                    return "too long";
                }
            }
           
            return null;
View Full Code Here

Examples of org.pdf4j.saxon.value.NumericValue

    public Item evaluateItem(XPathContext c) throws XPathException {
        AtomicValue av = (AtomicValue)value.evaluateItem(c);
        if (av==null) {
            return BooleanValue.FALSE;
        }
        NumericValue v = (NumericValue)av;

        if (!v.isWholeNumber()) {
            return BooleanValue.FALSE;
        }

        AtomicValue av2 = (AtomicValue)min.evaluateItem(c);
        NumericValue v2 = (NumericValue)av2;

        if (v.compareTo(v2) < 0) {
            return BooleanValue.FALSE;
        }

        AtomicValue av3 = (AtomicValue)max.evaluateItem(c);
        NumericValue v3 = (NumericValue)av3;

        return BooleanValue.get(v.compareTo(v3) <= 0);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.