-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add more logarithm constants #50539
Add more logarithm constants #50539
Conversation
r? @dtolnay (rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you share some example use cases that require these constants? I think I've never seen log10(2)
before.
@dtolnay Obviously these aren't super useful in every context, but I'd argue that |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Looking for some precedent I found that Go provides only the four we already have while D provides all six. I would be on board with landing these unstable. Please file a tracking issue and include the issue number in the PR. Thanks! |
Done! |
src/libcore/num/f32.rs
Outdated
@@ -128,10 +128,18 @@ pub mod consts { | |||
#[stable(feature = "rust1", since = "1.0.0")] | |||
pub const LOG2_E: f32 = 1.44269504088896340735992468100189214_f32; | |||
|
|||
/// log<sub>2</sub>(10) | |||
#[unstable(feature = "extra_log_consts", issue = "50539")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the tracking issue number and not the PR number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake; that's fixed now.
@bors r+ |
📌 Commit 23b6e46 has been approved by |
Add more logarithm constants Right now, we have `ln(2)` and `ln(10)`, but only `log2(e)` and `log10(e)`. This also adds `log2(10)` and `log10(2)` for consistency.
Rollup of 11 pull requests Successful merges: - #49988 (Mention Result<!, E> in never docs.) - #50148 (turn `ManuallyDrop::new` into a constant function) - #50456 (Update the Cargo submodule) - #50460 (Make `String::new()` const) - #50464 (Remove some transmutes) - #50505 (Added regression function match value test) - #50511 (Add some explanations for #[must_use]) - #50525 (Optimize string handling in lit_token().) - #50527 (Cleanup a `use` in a raw_vec test) - #50539 (Add more logarithm constants) - #49523 (Update RELEASES.md for 1.26.0) Failed merges:
Right now, we have
ln(2)
andln(10)
, but onlylog2(e)
andlog10(e)
. This also addslog2(10)
andlog10(2)
for consistency.