public override INumber Eval(RuntimeData runtime) { var den = this.Denominator.Eval(runtime); var num = this.Numerator.Eval(runtime); Fraction f = new Expression.Fraction(den, num); if (runtime.Setting.DoOptimize) { return(f.Optimise(runtime)); } else { return(f); } }
public override INumber Multiple(RuntimeData runtime, INumber val) { if (val is Number) { // Powあっても大丈夫 INumber res = new Expression.Fraction( this.Denominator, this.Numerator.Multiple(runtime, val) ); if (runtime.Setting.DoOptimize) { res = res.Optimise(runtime); } return(res); } if (val is Fraction) { INumber res = new Fraction( this.Denominator.Multiple(runtime, (val as Fraction).Denominator), this.Numerator.Multiple(runtime, (val as Fraction).Numerator)); if (runtime.Setting.DoOptimize) { return(res.Optimise(runtime)); } else { return(res); } } // 旧コード 2017/01/12 // return val.Multiple(runtime, this); { var res = this.Clone() as Fraction; res.Numerator = res.Numerator.Multiple(runtime, val); return(res); } }