LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Result of 1-2^2 in Evaluation VIs ?

The formular parser of the evaluation VIs calculates 1-2^2=5, as for 1+ (-2)^2.

The formula&expression nodes give -3, as expected (using ** instead of ^). 

 

Why that? Precedence of operators should be the same.

 

Dirk

0 Kudos
Message 1 of 2
(3,151 Views)

That's not just a precedence issue, that is plain wrong!  It still gets it wrong when you add a second '-' to make it 1 - -2^2.  It is funny since I would have expected it to either get the right answer for the wrong reason 1 - (-2)^2 (ie. use the minus sign as both negation and subtraction) or fail altogether by using the minus sign for negation and then finding no operator between 1 and (-2)^2.  It goes out of its way to insert an addition operation.

 

I have liked the evaluation VIs on a limited basis, and now that basis is very limited. 

0 Kudos
Message 2 of 2
(3,116 Views)