[Kst] Equation parser - a possible BUG.
George Staikos
staikos at kde.org
Mon Nov 22 05:55:10 CET 2004
On Saturday 20 November 2004 09:18, Ron Daisy wrote:
> As far as I understand you are the one that wrote the equation parser of
> kst.
>
> While playing with KST I found that the equation parsing failed to parse
> correctly the following equation:
>
> exp(-(x-1)^2)
>
> The problem is that it performs the unary minus operator before the power
> of 2 as dictated
> by the precedence rules of arithmetics. This problem will show it self in
> all similar equation
> and seems to be critical.
I just compared against bc(1) and it seems to behave different than you
describe, and different than we currently do. Therefore I wrote some
testcases which we can use to try to more precisely define what we want. We
had operator ^ behaving like this:
-x^y evaluates as: (-x)^y
x^y^z evaluates as: (x^y)^z
bc(1) has:
-x^y evaluates as: (-x)^y <------- same as we do
x^y^z evaluates as: x^(y^z) <---- different
This patch changes us to evaluate like this:
-x^y evaluates as: -(x^y)
x^y^z evaluates as: x^(y^z)
Now I'm not convinced that it's a good idea since it does the opposite of
bc(1). Can you test against other apps? What do they do?
Barth/Andrew: What do you think? Should this patch go in? If so, I won't
commit yet, but I will continue to write testcases tomorrow. Then I can
commit tomorrow night if no other issues pop up.
> Hope helping improving the KST quality,
Thanks!
--
George Staikos
KDE Developer http://www.kde.org/
Staikos Computing Services Inc. http://www.staikos.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eparserfixes.patch
Type: text/x-diff
Size: 1643 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kst/attachments/20041121/7a7d1b35/eparserfixes.bin
More information about the Kst
mailing list