/** Function constructor **/ public DoubleValue(DoubleValue result, NumberOperations function, DoubleValue... params) { super(function, params); this.value = result.doubleValue(); }
@Override public Double convert(DoubleValue param) { if (param == null) { return null; } return param.doubleValue(); };
/** Function constructor **/ public DoubleValue(DoubleValue result, NumberOperations function, DoubleValue... params) { super(function, params); this.value = result.doubleValue(); }
public Double marshal(DoubleValue val) throws Exception { return val.doubleValue(); } }
public Double marshal(DoubleValue val) throws Exception { return val.doubleValue(); } }
public static char cast(DoubleValue x, char y) { return (char) x.doubleValue(); }
public static double cast(DoubleValue x, double y) { return x.doubleValue(); }
public static char cast(DoubleValue x, char y) { return (char) x.doubleValue(); }
public static double cast(DoubleValue x, double y) { return x.doubleValue(); }
public static BigDecimal cast(DoubleValue x, BigDecimal y) { return BigDecimal.valueOf(x.doubleValue()); }
public static BigDecimal cast(DoubleValue x, BigDecimal y) { return BigDecimal.valueOf(x.doubleValue()); }
public boolean contains(DoubleValue value) { return contains(value.doubleValue()); }
public static Double convertToDouble(Object object) { if (Float.class.equals(object.getClass())) { return Double.valueOf(object.toString()); } if (FloatValue.class.isAssignableFrom(object.getClass())) { return Double.valueOf(object.toString()); } if (Double.class.equals(object.getClass())) { return (Double) object; } if (DoubleValue.class.isAssignableFrom(object.getClass())) { return ((DoubleValue) object).doubleValue(); } if (BigDecimal.class.equals(object.getClass())) { return ((BigDecimal) object).doubleValue(); } if (BigDecimalValue.class.equals(object.getClass())) { return ((BigDecimalValue) object).doubleValue(); } return null; }
/** * * @deprecated This method is obsolete. Use {@link #round(DoubleValue, int)} * instead * @see #round(DoubleValue, int) */ @Deprecated public static DoubleValue round(DoubleValue d, DoubleValue p) { if (d == null || p == null) { throw new OpenLRuntimeException("None of the arguments for 'round' operation can be null"); } int scale; double preRoundedValue; if (p.doubleValue() == 0) { scale = 0; preRoundedValue = d.doubleValue(); } else { scale = (int) Round.round(-Math.log10(p.doubleValue()), 0, Round.HALF_UP); preRoundedValue = d.doubleValue(); // preRoundedValue = Math.round(d.doubleValue() / p.doubleValue()) * // p.doubleValue(); } double roundedValue = Round.round(preRoundedValue, scale, Round.HALF_UP); return new DoubleValue(new DoubleValue(roundedValue), NumberOperations.ROUND, new DoubleValue[] { d, p }); }
/** * * @deprecated This method is obsolete. Use {@link #round(DoubleValue, int)} * instead * @see #round(DoubleValue, int) */ @Deprecated public static DoubleValue round(DoubleValue d, DoubleValue p) { if (d == null || p == null) { throw new OpenLRuntimeException("None of the arguments for 'round' operation can be null"); } int scale; double preRoundedValue; if (p.doubleValue() == 0) { scale = 0; preRoundedValue = d.doubleValue(); } else { scale = (int) Round.round(-Math.log10(p.doubleValue()), 0, Round.HALF_UP); preRoundedValue = d.doubleValue(); // preRoundedValue = Math.round(d.doubleValue() / p.doubleValue()) * // p.doubleValue(); } double roundedValue = Round.round(preRoundedValue, scale, Round.HALF_UP); return new DoubleValue(new DoubleValue(roundedValue), NumberOperations.ROUND, new DoubleValue[] { d, p }); }
/** * Divides left hand operand by right hand operand * @param value1 org.openl.meta.DoubleValue * @param value2 org.openl.meta.DoubleValue * @return the result of division operation */ public static org.openl.meta.DoubleValue divide(org.openl.meta.DoubleValue value1, org.openl.meta.DoubleValue value2) { // temporary commented to support operations with nulls // // validate(value1, value2, Formulas.DIVIDE.toString()); if (value1 == null && value2 == null) { return null; } if (value1 == null) { if (value2 != null && value2.doubleValue() != 0) { return new org.openl.meta.DoubleValue(value1, value2, divide(ONE, value2).getValue(), Formulas.DIVIDE); } } if (value2 == null) { return new org.openl.meta.DoubleValue(value1, value2, value1.getValue(), Formulas.DIVIDE); } if (value2.doubleValue() == 0) { // FIXME: temporary commented the throwing exception // Is needed for the one of the commercial products, pls contact Denis Levchuk // return new org.openl.meta.DoubleValue(value1, value2, Double.POSITIVE_INFINITY, Formulas.DIVIDE); } return new org.openl.meta.DoubleValue(value1, value2, Operators.divide(value1.getValue(), value2.getValue()), Formulas.DIVIDE); }
/** * Divides left hand operand by right hand operand * @param value1 org.openl.meta.DoubleValue * @param value2 org.openl.meta.DoubleValue * @return the result of division operation */ public static org.openl.meta.DoubleValue divide(org.openl.meta.DoubleValue value1, org.openl.meta.DoubleValue value2) { // temporary commented to support operations with nulls // // validate(value1, value2, Formulas.DIVIDE.toString()); if (value1 == null && value2 == null) { return null; } if (value1 == null) { if (value2 != null && value2.doubleValue() != 0) { return new org.openl.meta.DoubleValue(value1, value2, divide(ONE, value2).getValue(), Formulas.DIVIDE); } } if (value2 == null) { return new org.openl.meta.DoubleValue(value1, value2, value1.getValue(), Formulas.DIVIDE); } if (value2.doubleValue() == 0) { // FIXME: temporary commented the throwing exception // Is needed for the one of the commercial products, pls contact Denis Levchuk // return new org.openl.meta.DoubleValue(value1, value2, Double.POSITIVE_INFINITY, Formulas.DIVIDE); } return new org.openl.meta.DoubleValue(value1, value2, Operators.divide(value1.getValue(), value2.getValue()), Formulas.DIVIDE); }