I am trying to use nCalc in my application but am running into issues with it wanting to convert to UInt16 for whatever reason and causing an error.
string evalstring = "-.503937 ^ 2";
Expression e = new Expression(evalstring);
this.Value = Convert.ToDouble(e.Evaluate());
This throws;
System.OverflowException occurred
HResult=-2146233066
Message=Value was either too large or too small for a UInt16.
Source=mscorlib
StackTrace:
at System.Convert.ToUInt16(Int32 value)
InnerException:
In an NCalc expression,
^is the bitwise XOR operator, which accepts two unsigned 16-bit integer operands. In your expression, NCalc attempts to convert-.503937to a UInt16 value, andOverflowExceptionis thrown because the number is less than zero.If you want exponentiation, use the
Powfunction instead: