public IfValue Calculate(string op, IfValue v=null) { switch (op) { case "+": return new DecValue(this.GetFloat() + v.GetFloat()); case "-": return new DecValue(this.GetFloat() - v.GetFloat()); case "*": return new DecValue(this.GetFloat() * v.GetFloat()); case "/": return new DecValue(this.GetFloat() / v.GetFloat()); default: return new DecValue(this.GetFloat()); } }
public IfValue Calculate(string op, IfValue v=null) { switch (op) { case "+": if (v != null) return new DecValue(this.Value + v.GetFloat()); else return new DecValue(this.Value); case "-": if (v != null) return new DecValue(this.Value - v.GetFloat()); else return new DecValue(-this.Value); case "*": if (v != null) return new DecValue(this.Value * v.GetFloat()); else throw new RuntimeError("right operand missing in expression"); case "/": if (v != null) return new DecValue(this.Value / v.GetFloat()); else throw new RuntimeError("right operand missing in expression"); default: throw new RuntimeError("unknown operator " + op + " in expression"); } }
public IfValue Calculate(string op, IfValue v = null) { switch (op) { case "+": return(new DecValue(this.GetFloat() + v.GetFloat())); case "-": return(new DecValue(this.GetFloat() - v.GetFloat())); case "*": return(new DecValue(this.GetFloat() * v.GetFloat())); case "/": return(new DecValue(this.GetFloat() / v.GetFloat())); default: return(new DecValue(this.GetFloat())); } }
public IfValue Calculate(string op, IfValue v = null) { switch (op) { case "+": if (v != null) { return(new DecValue(this.Value + v.GetFloat())); } else { return(new DecValue(this.Value)); } case "-": if (v != null) { return(new DecValue(this.Value - v.GetFloat())); } else { return(new DecValue(-this.Value)); } case "*": if (v != null) { return(new DecValue(this.Value * v.GetFloat())); } else { throw new RuntimeError("right operand missing in expression"); } case "/": if (v != null) { return(new DecValue(this.Value / v.GetFloat())); } else { throw new RuntimeError("right operand missing in expression"); } default: throw new RuntimeError("unknown operator " + op + " in expression"); } }
public void Set(IfValue v) { this.Value = v.GetFloat(); }
public void Set( IfValue v ) { this.Value = v.GetFloat(); }