summaryrefslogtreecommitdiffstats
path: root/library/core/src/num/f32.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /library/core/src/num/f32.rs
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/core/src/num/f32.rs')
-rw-r--r--library/core/src/num/f32.rs44
1 files changed, 41 insertions, 3 deletions
diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs
index 290f649f9..f60626b00 100644
--- a/library/core/src/num/f32.rs
+++ b/library/core/src/num/f32.rs
@@ -377,6 +377,13 @@ impl f32 {
pub const MANTISSA_DIGITS: u32 = 24;
/// Approximate number of significant digits in base 10.
+ ///
+ /// This is the maximum <i>x</i> such that any decimal number with <i>x</i>
+ /// significant digits can be converted to `f32` and back without loss.
+ ///
+ /// Equal to floor(log<sub>10</sub>&nbsp;2<sup>[`MANTISSA_DIGITS`]&nbsp;&minus;&nbsp;1</sup>).
+ ///
+ /// [`MANTISSA_DIGITS`]: f32::MANTISSA_DIGITS
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
pub const DIGITS: u32 = 6;
@@ -384,31 +391,62 @@ impl f32 {
///
/// This is the difference between `1.0` and the next larger representable number.
///
+ /// Equal to 2<sup>1&nbsp;&minus;&nbsp;[`MANTISSA_DIGITS`]</sup>.
+ ///
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
+ /// [`MANTISSA_DIGITS`]: f32::MANTISSA_DIGITS
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
pub const EPSILON: f32 = 1.19209290e-07_f32;
/// Smallest finite `f32` value.
+ ///
+ /// Equal to &minus;[`MAX`].
+ ///
+ /// [`MAX`]: f32::MAX
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
pub const MIN: f32 = -3.40282347e+38_f32;
/// Smallest positive normal `f32` value.
+ ///
+ /// Equal to 2<sup>[`MIN_EXP`]&nbsp;&minus;&nbsp;1</sup>.
+ ///
+ /// [`MIN_EXP`]: f32::MIN_EXP
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
pub const MIN_POSITIVE: f32 = 1.17549435e-38_f32;
/// Largest finite `f32` value.
+ ///
+ /// Equal to
+ /// (1&nbsp;&minus;&nbsp;2<sup>&minus;[`MANTISSA_DIGITS`]</sup>)&nbsp;2<sup>[`MAX_EXP`]</sup>.
+ ///
+ /// [`MANTISSA_DIGITS`]: f32::MANTISSA_DIGITS
+ /// [`MAX_EXP`]: f32::MAX_EXP
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
pub const MAX: f32 = 3.40282347e+38_f32;
/// One greater than the minimum possible normal power of 2 exponent.
+ ///
+ /// If <i>x</i>&nbsp;=&nbsp;`MIN_EXP`, then normal numbers
+ /// ≥&nbsp;0.5&nbsp;×&nbsp;2<sup><i>x</i></sup>.
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
pub const MIN_EXP: i32 = -125;
/// Maximum possible power of 2 exponent.
+ ///
+ /// If <i>x</i>&nbsp;=&nbsp;`MAX_EXP`, then normal numbers
+ /// &lt;&nbsp;1&nbsp;×&nbsp;2<sup><i>x</i></sup>.
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
pub const MAX_EXP: i32 = 128;
- /// Minimum possible normal power of 10 exponent.
+ /// Minimum <i>x</i> for which 10<sup><i>x</i></sup> is normal.
+ ///
+ /// Equal to ceil(log<sub>10</sub>&nbsp;[`MIN_POSITIVE`]).
+ ///
+ /// [`MIN_POSITIVE`]: f32::MIN_POSITIVE
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
pub const MIN_10_EXP: i32 = -37;
- /// Maximum possible power of 10 exponent.
+ /// Maximum <i>x</i> for which 10<sup><i>x</i></sup> is normal.
+ ///
+ /// Equal to floor(log<sub>10</sub>&nbsp;[`MAX`]).
+ ///
+ /// [`MAX`]: f32::MAX
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
pub const MAX_10_EXP: i32 = 38;
@@ -820,7 +858,7 @@ impl f32 {
/// let angle = std::f32::consts::PI;
///
/// let abs_difference = (angle.to_degrees() - 180.0).abs();
- ///
+ /// # #[cfg(any(not(target_arch = "x86"), target_feature = "sse2"))]
/// assert!(abs_difference <= f32::EPSILON);
/// ```
#[must_use = "this returns the result of the operation, \