public void divideValue(Decimal divisor) throws UcumException { value = value.divide(divisor); }
public Decimal divInt(Decimal other) throws UcumException { if (other == null) return null; Decimal t = divide(other); return t.trunc(); }
public void divideValue(int divisor) throws UcumException { value = value.divide(new Decimal(divisor)); }
@Override public Decimal getValue() { try { return new Decimal(5).divide(new Decimal(9)); } catch (Exception e) { // won't happen return null; } }
d1 = new Decimal(l.primitiveValue()); Decimal d2 = new Decimal(r.primitiveValue()); result.add(new DecimalType(d1.divide(d2).asDecimal())); } catch (UcumException e) { throw new PathEngineException(e);
public void divideValue(Decimal divisor) throws UcumException { value = value.divide(divisor); }
@Override public Decimal convert(Decimal value, String sourceUnit, String destUnit) throws UcumException { assert value != null : paramError("convert", "value", "must not be null"); assert checkStringParam(sourceUnit) : paramError("convert", "sourceUnit", "must not be null or empty"); assert checkStringParam(destUnit) : paramError("convert", "destUnit", "must not be null or empty"); if (sourceUnit.equals(destUnit)) return value; Canonical src = new Converter(model, handlers).convert(new ExpressionParser(model).parse(sourceUnit)); Canonical dst = new Converter(model, handlers).convert(new ExpressionParser(model).parse(destUnit)); String s = new ExpressionComposer().compose(src, false); String d = new ExpressionComposer().compose(dst, false); if (!s.equals(d)) throw new UcumException("Unable to convert between units "+sourceUnit+" and "+destUnit+" as they do not have matching canonical forms ("+s+" and "+d+" respectively)"); Decimal canValue = value.multiply(src.getValue()); // System.out.println(value.toPlainString()+sourceUnit+" =("+src.getValue().toPlainString()+")= "+ // canValue.toPlainString()+s+" =("+dst.getValue().toPlainString()+")= "+ // canValue.divide(dst.getValue())+destUnit); return canValue.divide(dst.getValue()); }
public void divideValue(int divisor) throws UcumException { value = value.divide(new Decimal(divisor)); }
public Decimal divInt(Decimal other) throws UcumException { if (other == null) return null; Decimal t = divide(other); return t.trunc(); }
@Override public Decimal getValue() { try { return new Decimal(5).divide(new Decimal(9)); } catch (Exception e) { // won't happen return null; } }
d1 = new Decimal(l.primitiveValue()); Decimal d2 = new Decimal(r.primitiveValue()); result.add(new DecimalType(d1.divide(d2).asDecimal())); } catch (UcumException e) { throw new PathEngineException(e);
@Override public Decimal convert(Decimal value, String sourceUnit, String destUnit) throws UcumException { assert value != null : paramError("convert", "value", "must not be null"); assert checkStringParam(sourceUnit) : paramError("convert", "sourceUnit", "must not be null or empty"); assert checkStringParam(destUnit) : paramError("convert", "destUnit", "must not be null or empty"); if (sourceUnit.equals(destUnit)) return value; Canonical src = new Converter(model, handlers).convert(new ExpressionParser(model).parse(sourceUnit)); Canonical dst = new Converter(model, handlers).convert(new ExpressionParser(model).parse(destUnit)); String s = new ExpressionComposer().compose(src, false); String d = new ExpressionComposer().compose(dst, false); if (!s.equals(d)) throw new UcumException("Unable to convert between units "+sourceUnit+" and "+destUnit+" as they do not have matching canonical forms ("+s+" and "+d+" respectively)"); Decimal canValue = value.multiply(src.getValue()); // System.out.println(value.toPlainString()+sourceUnit+" =("+src.getValue().toPlainString()+")= "+ // canValue.toPlainString()+s+" =("+dst.getValue().toPlainString()+")= "+ // canValue.divide(dst.getValue())+destUnit); return canValue.divide(dst.getValue()); }