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

Suggestion: Overload operator % in C++ API #2487

Closed
linkret opened this issue Aug 13, 2019 · 2 comments
Closed

Suggestion: Overload operator % in C++ API #2487

linkret opened this issue Aug 13, 2019 · 2 comments

Comments

@linkret
Copy link

linkret commented Aug 13, 2019

Currently I have to use z3::mod(expr_a, expr_b), which is okay, but if all the other operators got overloaded, this one could (should?) be as well.

Also, it's currently possible to just type (expr_a) % (expr_b), and it compiles, but this won't return an z3::expr, but a number, I think? And it won't be the correct number, but some junk? In my opinion overloading operator% with z3::mod(a,b) would be better, so that people don't accidentally do this.

I'm using stable build 4.8.5 for Windows x64.

@NikolajBjorner
Copy link
Contributor

sounds reasonable. There is both a 'mod' and a 'rem'. Conventions should be similar for python, thus mod in python is %. For arithmetic it translates to mod, for bit-vectors to bvsmod, and for floating points to fpRem. Perhaps this is arbitrary.

@wintersteiger
Copy link
Contributor

I think that C++ does not provide a default implementation for % on floats/doubles, because it wouldn't be clear which flavor of mod it should be (fmod, remainder*, FPREM1). So, I don't think we should provide one either. For ints and bit-vectors I think it would be fine too.

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

3 participants