Skip to content

Commit

Permalink
Rollup merge of rust-lang#66157 - srinivasreddy:improv, r=alexcrichton
Browse files Browse the repository at this point in the history
Improve math log documentation examples

using 2.0.log(2.0) in examples does not make it clear which is the base and number. This example makes it clear for programmers who take a glance at the example by following the calculation. It is more intuitive, and eliminates the need for executing the example in the playground.
  • Loading branch information
JohnTitor authored Nov 8, 2019
2 parents 392ebad + 62167c0 commit 1455381
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/libstd/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,10 @@ impl f64 {
/// # Examples
///
/// ```
/// let five = 5.0_f64;
/// let twenty_five = 25.0_f64;
///
/// // log5(5) - 1 == 0
/// let abs_difference = (five.log(5.0) - 1.0).abs();
/// // log5(25) - 2 == 0
/// let abs_difference = (twenty_five.log(5.0) - 2.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// ```
Expand All @@ -425,10 +425,10 @@ impl f64 {
/// # Examples
///
/// ```
/// let two = 2.0_f64;
/// let four = 4.0_f64;
///
/// // log2(2) - 1 == 0
/// let abs_difference = (two.log2() - 1.0).abs();
/// // log2(4) - 2 == 0
/// let abs_difference = (four.log2() - 2.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// ```
Expand All @@ -448,10 +448,10 @@ impl f64 {
/// # Examples
///
/// ```
/// let ten = 10.0_f64;
/// let hundred = 100.0_f64;
///
/// // log10(10) - 1 == 0
/// let abs_difference = (ten.log10() - 1.0).abs();
/// // log10(100) - 2 == 0
/// let abs_difference = (hundred.log10() - 2.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// ```
Expand Down

0 comments on commit 1455381

Please sign in to comment.