govaluate
govaluate copied to clipboard
Supporting negative values
I am seeing a lot of my users doing expressions like this which are causing problems 5*-3
. What they mean is 5*(-3)
, but they are expecting the evaluation to work. The same for something like 5*+3
, which does not evaluate without error.
I wonder if there is a way to make the expression handling more robust so it can handle -/+ signing of values without requiring brackets?
Huh, I'm surprised I didn't have a test case for this - this should work. But it looks like I only made test cases for when the prefixed value is on the left-hand side of such an expression (like -1 > foo
). This is definitely a bug.
@Knetic Problem does not been fixed?
expression, _ := govaluate.NewEvaluableExpression("32.9<-10")
result, _ := expression.Evaluate(nil)
log.Println(result)
Not work, Error:
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
Oh! Looks like <-
caused the problem, 32.9 < -10
worked, 32.9 <-10
not.
So, must have space between Logical symbol.