0

I am trying to evaluate the following expression:

7088.800/(((((((24.65995+24.43061+24.54517+24.65192)/4)-32.0)*5/9)+273.15)/288.15)^.5)

If you are asking yourself why I didn't use Sqrt() instead of ^0.5 it's because I'm doing some things with the string beforehand that require there be no letters.

I am using this simple code:

Expression.CacheEnabled = False
x = New Expression(xEquation)
y = New Expression(yEquation)
System.Diagnostics.Debug.Write(x.Error)
System.Diagnostics.Debug.Write(y.Error)
Return New PointF(x.Evaluate, y.Evaluate)

The answer I get is: 7088.800

The correct answer is:7336.46922305(according to google)

I am using .net 3.5 and ncalc 1.3.8

I suspect it doesn't like the amount of brackets there are but I can't find any mention of that being a problem anywhere...

Thanks!

4

1 回答 1

1

我无法让 Ncalc 或 Ncalc-edge (v1.4.1) 使用幂运算符^并产生正确的结果。例如,“4 ^ 2”给出 6。它不接受**作为运算符。

一点点调查表明它以C# 的风格^用作运算符。XorC# 没有求幂运算符,因此您必须设计一种解析实际输入字符串并使用Sqrt.

目前 Ncalc 论坛上有一些关于此的请求,例如Override ^ operator

于 2016-04-01T18:10:53.530 回答