- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在我的应用程序中使用 nCalc,但遇到了问题,无论出于何种原因想要转换为 UInt16 并导致错误。
string evalstring = "-.503937 ^ 2";
Expression e = new Expression(evalstring);
this.Value = Convert.ToDouble(e.Evaluate());
这抛出;
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:
最佳答案
在 NCalc 表达式中,^
是按位异或运算符,它接受两个无符号 16 位整数操作数。在您的表达式中,NCalc 尝试将 -.503937
转换为 UInt16 值,并抛出 OverflowException
,因为数字小于零。
如果你想求幂,请改用 Pow
函数:
string evalstring = "Pow(-.503937, 2)";
关于c# - 阻止 nCalc 使用 ToUInt16()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38545490/
我们有一个使用 Ncalc 计算字符串的通用计算例程。然而,当乘法中的值足够小以至于 Ncalc 将它们视为 int 但结果对于 int 来说太大时,我们遇到了一个问题。 例子: va
我在项目中使用 NCalc。有没有办法像这样进行日期操作 #16/02/2013# - #15/02/2013# = 1 我好像出不出结果。 Expression.Evaluate(); 上述表达式的
有谁知道比 NCalc 更新的表达式求值器?上一次发布是在 2011 年,根据我所见,(非常)快速的 Google 搜索几乎没有返回任何结果。 最佳答案 我知道这是一个迟到的回复,但为了其他搜索者以及
我想提示用户输入一个数字,然后使用 NCalc 计算和求解公式 string a = Console.ReadKey().ToString(); Expression e = new Expressi
我在我的新项目中使用 Ncalc,它几乎已经具备了我需要的一切。 我几乎都说了,因为现在我需要扩展一些功能,还要添加新的功能,例如:nth root,random 等 您知道是否有人已经实现了这些功能
我在我的项目中使用 NCalc 来计算表达式。该框架包括一组已实现的功能,可以在 here 中找到。 。 我对计算数字或字符串的长度感兴趣。我可以仅使用内置函数来实现这一点吗? 最佳答案 要获取整数的
我在使用 NCalc 时遇到了问题:我正在尝试通过将表达式写入文本框来实现一种向我的程序添加表达式的方法,然后让程序使用它来对变量求和/乘法。这是一个例子: Expression expr = new
我有一个表达式,我想解析它以获得所有使用的参数的列表。 For example: "X + 5 / (Y - 1)" should give me the following result: X, Y
我正在尝试在我的应用程序中使用 nCalc,但遇到了问题,无论出于何种原因想要转换为 UInt16 并导致错误。 string evalstring = "-.503937 ^ 2"; Express
在 vb2010 而不是 c# 中创建自定义函数的等效代码是什么? Expression e = new Expression("SecretOperation(3, 6)"); e.Eval
有没有办法在 Windows Phone 8 项目上使用 Ncalc?如果没有,还有其他选择吗? 我通过 nuget 将它添加到我的项目中,但是当我尝试计算一个表达式时它抛出一个异常 A first
我是一名优秀的程序员,十分优秀!