Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

precision lost #154

Open
leeqvip opened this issue Sep 15, 2021 · 1 comment
Open

precision lost #154

leeqvip opened this issue Sep 15, 2021 · 1 comment

Comments

@leeqvip
Copy link

leeqvip commented Sep 15, 2021

	expression, err := govaluate.NewEvaluableExpression("(0.05 + 0.01) > 0.06")
	assert.NoError(t, err)
	result, err := expression.Evaluate(nil)
	assert.NoError(t, err)
	assert.Equal(t, false, result.(bool))

Error: Not equal:
expected: false
actual : true

@hesining
Copy link

hesining commented Mar 10, 2022

It's the golang float problem, you can try this code

` var a float64 = 0.05

var b float64 = 0.01

var c float64 = 0.06

fmt.Println("a + b   ", a+b)

fmt.Println(" (a+b) > c   ", (a+b) > c)

fmt.Println("(0.05+0.01) > 0.06  ", (0.05+0.01) > 0.06)`

nothing to do with govaluate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants