示例#1
0
 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));
 }
示例#2
0
 internal NumericProperty(Numeric value)
 {
     this.numeric = value;
 }
示例#3
0
 private Property evalNegate(Numeric op)
 {
     if (op == null)
     {
         throw new PropertyException("Non numeric operand to unary minus");
     }
     return new NumericProperty(op.multiply(negOne));
 }
示例#4
0
 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));
 }
示例#5
0
 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));
 }
示例#6
0
 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));
 }
示例#7
0
文件: Numeric.cs 项目: nholik/Fo.Net
 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.");
 }
示例#8
0
文件: Numeric.cs 项目: nholik/Fo.Net
 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.");
     }
 }
示例#9
0
文件: Numeric.cs 项目: nholik/Fo.Net
 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");
     }
 }
示例#10
0
文件: Numeric.cs 项目: nholik/Fo.Net
 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");
     }
 }
 internal NumericProperty(Numeric value)
 {
     this.numeric = value;
 }