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

Emulate OP_MULDIV #151

Open
rkalis opened this issue Jun 29, 2023 · 0 comments
Open

Emulate OP_MULDIV #151

rkalis opened this issue Jun 29, 2023 · 0 comments
Milestone

Comments

@rkalis
Copy link
Member

rkalis commented Jun 29, 2023

In this BCR post OP_MULDIV is mentioned as a possible solution for overflowing intermediate values when multiplying and dividing after each other.

For example:

2^63 * 2^50 / 2^63

In the example above, the intermediate result of 2^63 * 2^50 would overflow, while the full result of 2^63 * 2^50 / 2^63 would not.

While OP_MULDIV doesn't exist now, some people are emulating this using division and modulo operations (e.g. the old AnyHedge).

We could abstract away this emulation into something like muldiv(2^63, 2^50, 2^63). That would make this emulation that contract devs do less error prone and much easier to read because it is handled by the compiler, not the developer.

@rkalis rkalis added this to the v1 milestone Nov 8, 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