Placing each operator at its own precedence level subtly alters the
evaluation order for +, -, *, and /, which can produce unexpected
results where rounding errors are considered.

More significantly, the precendence of % differs from that used in
C (and various other languages). For example,

2 * 3.1 % 2  with C precedence would be
(2 * 3.1) % 2 = 6.2 % 2 = 0.2   (unlike C's %, our % if really fmod)

By giving % higher precedence than *, we get
2 * (3.1 % 2) = 2 * 1.1 = 2.2  instead.

I don't know if this difference is intentional, e.g., required for
compatibility with Milkdrop. But it does at least look suspicious.

- Werner

---
 software/libfpvm/parser.y |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/software/libfpvm/parser.y b/software/libfpvm/parser.y
index 0e9f144..0cf2821 100644
--- a/software/libfpvm/parser.y
+++ b/software/libfpvm/parser.y
@@ -53,11 +53,8 @@ node(N) ::= TOK_IDENT(I). {
        N->contents.branches.c = NULL;
 }
 
-%left TOK_PLUS.
-%left TOK_MINUS.
-%left TOK_MULTIPLY.
-%left TOK_DIVIDE.
-%left TOK_PERCENT.
+%left TOK_PLUS TOK_MINUS.
+%left TOK_MULTIPLY TOK_DIVIDE TOK_PERCENT.
 %left TOK_NOT.
 
 node(N) ::= node(A) TOK_PLUS node(B). {
-- 
1.7.1

_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode

Reply via email to