You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It also damage the performance, Because logically you could abort the calculation in line:
[][(X1 & X2) | (X3 & X4) | X5 & X6] Parsing (0, 6) ---> 0 | 1 | 1 & 0 ... ---> 1 | 1 & 0 ... done
and return 1 as result
The text was updated successfully, but these errors were encountered:
IdanVT
changed the title
wrong
Possible wrong result from calculate function
May 13, 2019
Thank you, but mXparser does not follow .net/java precedence. In general math there is no clear precedence defined for logical operators, the same is in case of natural language, thus you should always use parenthesis. I will consider precedence introduction.
Issue title:
Possible wrong result from calculate function
If bug/question:
Wrong boolean operators calculation order
`
Consider the following code:
`
ans2 which is the equivalent expression return true
ans return 0 (false)
if i setVerboseMode I'm getting a wrong calculation order
Verbose output:
[][(X1 & X2) | (X3 & X4) | X5 & X6] Starting ...
[][(X1 & X2) | (X3 & X4) | X5 & X6] X1 = 0
[][(X1 & X2) | (X3 & X4) | X5 & X6] X2 = 1
[][(X1 & X2) | (X3 & X4) | X5 & X6] X3 = 1
[][(X1 & X2) | (X3 & X4) | X5 & X6] X4 = 1
[][(X1 & X2) | (X3 & X4) | X5 & X6] X5 = 1
[][(X1 & X2) | (X3 & X4) | X5 & X6] X6 = 0
[][(X1 & X2) | (X3 & X4) | X5 & X6] Starting calculation loop
[][(X1 & X2) | (X3 & X4) | X5 & X6] Parsing (0, 4) ---> ( 0 & 1 ) ... ---> ( 0 ) | ( 1 & 1 ) | 1 & 0 ... done
[][(X1 & X2) | (X3 & X4) | X5 & X6] Parsing (0, 2) ---> ( 0 ) ... ---> 0 | ( 1 & 1 ) | 1 & 0 ... done
[][(X1 & X2) | (X3 & X4) | X5 & X6] Parsing (2, 6) ---> ( 1 & 1 ) ... ---> 0 | ( 1 ) | 1 & 0 ... done
[][(X1 & X2) | (X3 & X4) | X5 & X6] Parsing (2, 4) ---> ( 1 ) ... ---> 0 | 1 | 1 & 0 ... done
[][(X1 & X2) | (X3 & X4) | X5 & X6] Parsing (0, 6) ---> 0 | 1 | 1 & 0 ... ---> 1 | 1 & 0 ... done
[][(X1 & X2) | (X3 & X4) | X5 & X6] Parsing (0, 4) ---> 1 | 1 & 0 ... ---> 1 & 0 ... done
[][(X1 & X2) | (X3 & X4) | X5 & X6] Parsing (0, 2) ---> 1 & 0 ... ---> 0 ... done
[][(X1 & X2) | (X3 & X4) | X5 & X6] Calculated value: 0
[][(X1 & X2) | (X3 & X4) | X5 & X6] Exiting
as you can see there is a wrong order calculation in lines:
[][(X1 & X2) | (X3 & X4) | X5 & X6] Parsing (0, 6) ---> 0 | 1 | 1 & 0 ... ---> 1 | 1 & 0 ... done
[][(X1 & X2) | (X3 & X4) | X5 & X6] Parsing (0, 4) ---> 1 | 1 & 0 ... ---> 1 & 0 ... done
while it should be
[][(X1 & X2) | (X3 & X4) | X5 & X6] Parsing (0, 6) ---> 0 | 1 | 1 & 0 ... ---> 0 | 1 | 0 ... done
[][(X1 & X2) | (X3 & X4) | X5 & X6] Parsing (0, 6) ---> 0 | 1 | 0 ... ---> 1 | 0 ... done
[][(X1 & X2) | (X3 & X4) | X5 & X6] Parsing (0, 4) ---> 1 | 0 ... ---> 1 ... done
[][(X1 & X2) | (X3 & X4) | X5 & X6] Calculated value: 0
[][(X1 & X2) | (X3 & X4) | X5 & X6] Exiting
It also damage the performance, Because logically you could abort the calculation in line:
[][(X1 & X2) | (X3 & X4) | X5 & X6] Parsing (0, 6) ---> 0 | 1 | 1 & 0 ... ---> 1 | 1 & 0 ... done
and return 1 as result
The text was updated successfully, but these errors were encountered: