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

Comparing Int with float unexpected results #6482

Closed
Wout4 opened this issue Dec 7, 2022 · 0 comments
Closed

Comparing Int with float unexpected results #6482

Wout4 opened this issue Dec 7, 2022 · 0 comments

Comments

@Wout4
Copy link

Wout4 commented Dec 7, 2022

comparing an integer decision variable with a floating point number gives wrong results because the float gets converted to an integer

example in python:
x = Int('x')
s = Solver()
s.add(x >= 0.1)
s.add(x < 1)
print(s.check())
#sat but should be unsat
m = s.model()
print(m) #gives x = 0

I believe the issue is located in the function _coerce_exprs at line 1214 in z3.py
Because the rhs is not an expression it is typecast to the type of the lhs, in this case leading to the constraint x >= 0 instead of x >= 0.1

hgvk94 pushed a commit to hgvk94/z3 that referenced this issue Mar 27, 2023
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

1 participant