private Property evalDivide(Numeric op1, Numeric op2) { if (op1 == null || op2 == null) { throw new PropertyException("Non numeric operand in division"); } return new NumericProperty(op1.divide(op2)); }
internal NumericProperty(Numeric value) { this.numeric = value; }
private Property evalNegate(Numeric op) { if (op == null) { throw new PropertyException("Non numeric operand to unary minus"); } return new NumericProperty(op.multiply(negOne)); }
private Property evalMultiply(Numeric op1, Numeric op2) { if (op1 == null || op2 == null) { throw new PropertyException("Non numeric operand in multiplication"); } return new NumericProperty(op1.multiply(op2)); }
private Property evalAddition(Numeric op1, Numeric op2) { if (op1 == null || op2 == null) { throw new PropertyException("Non numeric operand in addition"); } return new NumericProperty(op1.add(op2)); }
private Property evalSubtraction(Numeric op1, Numeric op2) { if (op1 == null || op2 == null) { throw new PropertyException("Non numeric operand in subtraction"); } return new NumericProperty(op1.subtract(op2)); }
public Numeric min(Numeric op) { double rslt = 0.0; if (dim == op.dim && valType == op.valType && !isMixedType()) { if (valType == ABS_LENGTH) { rslt = absValue - op.absValue; } else if (valType == PC_LENGTH) { rslt = pcValue - op.pcValue; } else if (valType == TCOL_LENGTH) { rslt = tcolValue - op.tcolValue; } if (rslt > 0.0) { return op; } else { return this; } } throw new PropertyException("Arguments to min() must have same dimension and value type."); }
public Numeric divide(Numeric op) { if (dim == 0) { return new Numeric(op.valType, absValue / op.absValue, absValue / op.pcValue, absValue / op.tcolValue, -op.dim, op.pcBase); } else if (op.dim == 0) { double opval = op.absValue; return new Numeric(valType, absValue / opval, pcValue / opval, tcolValue / opval, dim, pcBase); } else if (valType == op.valType && !isMixedType()) { IPercentBase npcBase = ((valType & PC_LENGTH) != 0) ? pcBase : op.pcBase; return new Numeric(valType, (valType == ABS_LENGTH ? absValue / op.absValue : 0.0), (valType == PC_LENGTH ? pcValue / op.pcValue : 0.0), (valType == TCOL_LENGTH ? tcolValue / op.tcolValue : 0.0), dim - op.dim, npcBase); } else { throw new PropertyException("Can't divide mixed Numerics."); } }
public Numeric multiply(Numeric op) { if (dim == 0) { return new Numeric(op.valType, absValue * op.absValue, absValue * op.pcValue, absValue * op.tcolValue, op.dim, op.pcBase); } else if (op.dim == 0) { double opval = op.absValue; return new Numeric(valType, opval * absValue, opval * pcValue, opval * tcolValue, dim, pcBase); } else if (valType == op.valType && !isMixedType()) { IPercentBase npcBase = ((valType & PC_LENGTH) != 0) ? pcBase : op.pcBase; return new Numeric(valType, absValue * op.absValue, pcValue * op.pcValue, tcolValue * op.tcolValue, dim + op.dim, npcBase); } else { throw new PropertyException("Can't multiply mixed Numerics"); } }
public Numeric add(Numeric op) { if (dim == op.dim) { IPercentBase npcBase = ((valType & PC_LENGTH) != 0) ? pcBase : op.pcBase; return new Numeric(valType | op.valType, absValue + op.absValue, pcValue + op.pcValue, tcolValue + op.tcolValue, dim, npcBase); } else { throw new PropertyException("Can't add Numerics of different dimensions"); } }