Skip to content

Commit 1455381

Browse files
authored
Rollup merge of #66157 - srinivasreddy:improv, r=alexcrichton
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.
2 parents 392ebad + 62167c0 commit 1455381

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/libstd/f64.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,10 @@ impl f64 {
409409
/// # Examples
410410
///
411411
/// ```
412-
/// let five = 5.0_f64;
412+
/// let twenty_five = 25.0_f64;
413413
///
414-
/// // log5(5) - 1 == 0
415-
/// let abs_difference = (five.log(5.0) - 1.0).abs();
414+
/// // log5(25) - 2 == 0
415+
/// let abs_difference = (twenty_five.log(5.0) - 2.0).abs();
416416
///
417417
/// assert!(abs_difference < 1e-10);
418418
/// ```
@@ -425,10 +425,10 @@ impl f64 {
425425
/// # Examples
426426
///
427427
/// ```
428-
/// let two = 2.0_f64;
428+
/// let four = 4.0_f64;
429429
///
430-
/// // log2(2) - 1 == 0
431-
/// let abs_difference = (two.log2() - 1.0).abs();
430+
/// // log2(4) - 2 == 0
431+
/// let abs_difference = (four.log2() - 2.0).abs();
432432
///
433433
/// assert!(abs_difference < 1e-10);
434434
/// ```
@@ -448,10 +448,10 @@ impl f64 {
448448
/// # Examples
449449
///
450450
/// ```
451-
/// let ten = 10.0_f64;
451+
/// let hundred = 100.0_f64;
452452
///
453-
/// // log10(10) - 1 == 0
454-
/// let abs_difference = (ten.log10() - 1.0).abs();
453+
/// // log10(100) - 2 == 0
454+
/// let abs_difference = (hundred.log10() - 2.0).abs();
455455
///
456456
/// assert!(abs_difference < 1e-10);
457457
/// ```

0 commit comments

Comments
 (0)