-
Notifications
You must be signed in to change notification settings - Fork 148
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
Integrate common floating point constants #194
Comments
In general, |
Associated constants would be nice too, rust-lang/rust#29646, but we couldn't provide defaults there. |
I agree that pretty much every mathematical constant can be computed using the methods that are already there. However, |
No, I don't expect people should do that -- it's just a way to write a generic default so it's not a breaking change. We can provide the proper constants in the implementation for the concrete float types. Care to write up a PR? |
@cuviper, first of all, I apologize if it sounded rude; no offense was intended. I’m an active user of Yes, absolutely. If there are no objections, I’ll be happy to help. |
No problem, sorry if I sounded too defensive. :) |
Add a trait for floating-point constants The pull request is to address issue #194. In order to keep the library organized, I’ve introduced a new trait for the new functionality. The trait is supposed to closely follows the [`consts`](https://doc.rust-lang.org/std/f64/consts/index.html) module from the standard library. There are at least the following three open questions: 1. What should the name of the trait be? Currently, it’s `Constant`; an alternative is `Consts`. 2. What should the names of the getters be? Currently, they are lower-case versions of the constants defined in the `consts` module. Note that `Float` provides `log2` and `log10`, whereas `LOG_2` and `LOG_10` get translated into `log_2` and `log_10`, respectively. 3. Should `Float` require the new trait? Or should it be left up to the user? Please let me know what you think. Thank you! Regards, Ivan
Fixed by #220 -- thanks @IvanUkhov! |
In most of my implementations involving generic floating point values I have the need to work with pi and/or e. Thus it would be really helpful to provide static functions to retrieve those values for the concrete type.
The text was updated successfully, but these errors were encountered: