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

Support basic math constants #15

Open
cmpute opened this issue Nov 16, 2022 · 1 comment
Open

Support basic math constants #15

cmpute opened this issue Nov 16, 2022 · 1 comment
Milestone

Comments

@cmpute
Copy link
Owner

cmpute commented Nov 16, 2022

Support the following math constants under the dashu_float::consts module:

  • e(precision: usize) -> FBig<B, R>
  • pi(precision: usize) -> FBig<B, R>
  • ln2(precision: usize) -> FBig<B, R>
  • ln10(precision: usize) -> FBig<B, R>
  • sqrt2(precision: usize) -> FBig<B, R> (ref)

Furthermore, we might consider create a global buffer to store commonly used math constants (specifically pi, ln2 and ln10). This requires one of the following modifications:

  1. the context stores an Rc to the constants. In that case, the Context will be !Send and !Sync and we need to inform users that only Repr is Send and Sync.
  2. adding a global buffer (per thread / cross thread). This should be gated by a feature option, and we should provide a function (maybe associated with the Context type) to clear the buffer.
@cmpute cmpute modified the milestones: v0.5, v0.4 Nov 16, 2022
@cmpute
Copy link
Owner Author

cmpute commented Nov 28, 2022

After some investigation, it's hard to ensure that the buffer for constant is passed around easily without duplication. So I guess the implementation should rely on a thread local static buffer with RefCell. Then the implementation won't result in a break change and can be postponed to v0.5

@cmpute cmpute modified the milestones: v0.4, v0.5 Nov 29, 2022
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