diff options
| author | kennytm <kennytm@gmail.com> | 2018-05-09 17:24:44 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-05-09 17:24:44 +0800 |
| commit | 8e7f6dbdd720ebc48e6ef815ecb15fa5535e24cc (patch) | |
| tree | a6e540b37a9644253700e7f92a413e7b8a699974 | |
| parent | 0fa08507efe4187a8056691ceb550e9da1171863 (diff) | |
| parent | 23b6e465b9546b99c8b7609bfa4eeaf2094eed09 (diff) | |
| download | rust-8e7f6dbdd720ebc48e6ef815ecb15fa5535e24cc.tar.gz rust-8e7f6dbdd720ebc48e6ef815ecb15fa5535e24cc.zip | |
Rollup merge of #50539 - clarcharr:log_const, r=dtolnay
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.
| -rw-r--r-- | src/libcore/num/f32.rs | 8 | ||||
| -rw-r--r-- | src/libcore/num/f64.rs | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 8d5f6f601da..672119eba7f 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -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 = "50540")] + pub const LOG2_10: f32 = 3.32192809488736234787031942948939018_f32; + /// log<sub>10</sub>(e) #[stable(feature = "rust1", since = "1.0.0")] pub const LOG10_E: f32 = 0.434294481903251827651128918916605082_f32; + /// log<sub>10</sub>(2) + #[unstable(feature = "extra_log_consts", issue = "50540")] + pub const LOG10_2: f32 = 0.301029995663981195213738894724493027_f32; + /// ln(2) #[stable(feature = "rust1", since = "1.0.0")] pub const LN_2: f32 = 0.693147180559945309417232121458176568_f32; diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 08b869734d4..220b23a1e6a 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -124,10 +124,18 @@ pub mod consts { #[stable(feature = "rust1", since = "1.0.0")] pub const E: f64 = 2.71828182845904523536028747135266250_f64; + /// log<sub>2</sub>(10) + #[unstable(feature = "extra_log_consts", issue = "50540")] + pub const LOG2_10: f64 = 3.32192809488736234787031942948939018_f64; + /// log<sub>2</sub>(e) #[stable(feature = "rust1", since = "1.0.0")] pub const LOG2_E: f64 = 1.44269504088896340735992468100189214_f64; + /// log<sub>10</sub>(2) + #[unstable(feature = "extra_log_consts", issue = "50540")] + pub const LOG10_2: f64 = 0.301029995663981195213738894724493027_f64; + /// log<sub>10</sub>(e) #[stable(feature = "rust1", since = "1.0.0")] pub const LOG10_E: f64 = 0.434294481903251827651128918916605082_f64; |
