Auto merge of #104153 - tspiteri:doc-float-constants, r=workingjubilee · rust-lang/rust@90f3a6f

@@ -376,38 +376,76 @@ impl f64 {

376376

#[stable(feature = "assoc_int_consts", since = "1.43.0")]

377377

pub const MANTISSA_DIGITS: u32 = 53;

378378

/// Approximate number of significant digits in base 10.

379+

///

380+

/// This is the maximum <i>x</i> such that any decimal number with <i>x</i>

381+

/// significant digits can be converted to `f64` and back without loss.

382+

///

383+

/// Equal to floor(log<sub>10</sub>&nbsp;2<sup>[`MANTISSA_DIGITS`]&nbsp;&minus;&nbsp;1</sup>).

384+

///

385+

/// [`MANTISSA_DIGITS`]: f64::MANTISSA_DIGITS

379386

#[stable(feature = "assoc_int_consts", since = "1.43.0")]

380387

pub const DIGITS: u32 = 15;

381388382389

/// [Machine epsilon] value for `f64`.

383390

///

384391

/// This is the difference between `1.0` and the next larger representable number.

385392

///

393+

/// Equal to 2<sup>1&nbsp;&minus;&nbsp;[`MANTISSA_DIGITS`]</sup>.

394+

///

386395

/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon

396+

/// [`MANTISSA_DIGITS`]: f64::MANTISSA_DIGITS

387397

#[stable(feature = "assoc_int_consts", since = "1.43.0")]

388398

pub const EPSILON: f64 = 2.2204460492503131e-16_f64;

389399390400

/// Smallest finite `f64` value.

401+

///

402+

/// Equal to &minus;[`MAX`].

403+

///

404+

/// [`MAX`]: f64::MAX

391405

#[stable(feature = "assoc_int_consts", since = "1.43.0")]

392406

pub const MIN: f64 = -1.7976931348623157e+308_f64;

393407

/// Smallest positive normal `f64` value.

408+

///

409+

/// Equal to 2<sup>[`MIN_EXP`]&nbsp;&minus;&nbsp;1</sup>.

410+

///

411+

/// [`MIN_EXP`]: f64::MIN_EXP

394412

#[stable(feature = "assoc_int_consts", since = "1.43.0")]

395413

pub const MIN_POSITIVE: f64 = 2.2250738585072014e-308_f64;

396414

/// Largest finite `f64` value.

415+

///

416+

/// Equal to

417+

/// (1&nbsp;&minus;&nbsp;2<sup>&minus;[`MANTISSA_DIGITS`]</sup>)&nbsp;2<sup>[`MAX_EXP`]</sup>.

418+

///

419+

/// [`MANTISSA_DIGITS`]: f64::MANTISSA_DIGITS

420+

/// [`MAX_EXP`]: f64::MAX_EXP

397421

#[stable(feature = "assoc_int_consts", since = "1.43.0")]

398422

pub const MAX: f64 = 1.7976931348623157e+308_f64;

399423400424

/// One greater than the minimum possible normal power of 2 exponent.

425+

///

426+

/// If <i>x</i>&nbsp;=&nbsp;`MIN_EXP`, then normal numbers

427+

/// ≥&nbsp;0.5&nbsp;×&nbsp;2<sup><i>x</i></sup>.

401428

#[stable(feature = "assoc_int_consts", since = "1.43.0")]

402429

pub const MIN_EXP: i32 = -1021;

403430

/// Maximum possible power of 2 exponent.

431+

///

432+

/// If <i>x</i>&nbsp;=&nbsp;`MAX_EXP`, then normal numbers

433+

/// &lt;&nbsp;1&nbsp;×&nbsp;2<sup><i>x</i></sup>.

404434

#[stable(feature = "assoc_int_consts", since = "1.43.0")]

405435

pub const MAX_EXP: i32 = 1024;

406436407-

/// Minimum possible normal power of 10 exponent.

437+

/// Minimum <i>x</i> for which 10<sup><i>x</i></sup> is normal.

438+

///

439+

/// Equal to ceil(log<sub>10</sub>&nbsp;[`MIN_POSITIVE`]).

440+

///

441+

/// [`MIN_POSITIVE`]: f64::MIN_POSITIVE

408442

#[stable(feature = "assoc_int_consts", since = "1.43.0")]

409443

pub const MIN_10_EXP: i32 = -307;

410-

/// Maximum possible power of 10 exponent.

444+

/// Maximum <i>x</i> for which 10<sup><i>x</i></sup> is normal.

445+

///

446+

/// Equal to floor(log<sub>10</sub>&nbsp;[`MAX`]).

447+

///

448+

/// [`MAX`]: f64::MAX

411449

#[stable(feature = "assoc_int_consts", since = "1.43.0")]

412450

pub const MAX_10_EXP: i32 = 308;

413451