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

Overflow-handling strategies #9

Open
1011X opened this issue Feb 21, 2023 · 0 comments
Open

Overflow-handling strategies #9

1011X opened this issue Feb 21, 2023 · 0 comments

Comments

@1011X
Copy link
Owner

1011X commented Feb 21, 2023

floating_bar should decide on a default way to handle overflow for ops::Add and ops::Mul, and also include methods for different overflow-handling strategies so the user can decide which one is best for their use-case.

Strategies, in increasing order of complexity:

  • Lossless shift: shift out common powers of 2. Panic if not enough.
  • Lossy shift: shift out lowest bits until result fits in fraction field.
  • GCD reduce: divide by GCD. Panic if not enough.

The current plan is to use lossless shift as the default strategy since it is relatively quick and accurate, and floating_bar presents itself as a library focused on accuracy. The other behaviors will be available through a set of lossy_{add,mul}() and checked_{add,mul}() methods.

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