cmpute / dashu

A library set of arbitrary precision numbers implemented in Rust.
Apache License 2.0
76 stars 9 forks source link

Support basic math constants #15

Open cmpute opened 1 year ago

cmpute commented 1 year ago

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

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 commented 1 year ago

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