diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-04-24 17:19:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-24 17:19:46 +0200 |
| commit | 06126df8b83b27a108f8c72d4ab040d843700882 (patch) | |
| tree | 1eb266929b6fdcd063329e16dab8be7d74391b0b | |
| parent | 9dcb3678384a85c83267437882872f4ff52a7bad (diff) | |
| parent | 157caeed3e8b73bba883113b34b9f4d9d0779cbf (diff) | |
| download | rust-06126df8b83b27a108f8c72d4ab040d843700882.tar.gz rust-06126df8b83b27a108f8c72d4ab040d843700882.zip | |
Rollup merge of #140150 - RalfJung:MAX_EXP, r=tgross35
fix MAX_EXP and MIN_EXP docs As pointed out in https://github.com/rust-lang/rust/issues/88734, the docs for these constants are wrong. r? ``@tgross35``
| -rw-r--r-- | library/core/src/num/f128.rs | 18 | ||||
| -rw-r--r-- | library/core/src/num/f16.rs | 18 | ||||
| -rw-r--r-- | library/core/src/num/f32.rs | 18 | ||||
| -rw-r--r-- | library/core/src/num/f64.rs | 18 |
4 files changed, 48 insertions, 24 deletions
diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs index 3061ec208ba..8a72779ce87 100644 --- a/library/core/src/num/f128.rs +++ b/library/core/src/num/f128.rs @@ -197,16 +197,22 @@ impl f128 { #[unstable(feature = "f128", issue = "116909")] pub const MAX: f128 = 1.18973149535723176508575932662800702e+4932_f128; - /// One greater than the minimum possible normal power of 2 exponent. + /// One greater than the minimum possible *normal* power of 2 exponent + /// for a significand bounded by 1 ≤ x < 2 (i.e. the IEEE definition). /// - /// If <i>x</i> = `MIN_EXP`, then normal numbers - /// ≥ 0.5 × 2<sup><i>x</i></sup>. + /// This corresponds to the exact minimum possible *normal* power of 2 exponent + /// for a significand bounded by 0.5 ≤ x < 1 (i.e. the C definition). + /// In other words, all normal numbers representable by this type are + /// greater than or equal to 0.5 × 2<sup><i>MIN_EXP</i></sup>. #[unstable(feature = "f128", issue = "116909")] pub const MIN_EXP: i32 = -16_381; - /// Maximum possible power of 2 exponent. + /// One greater than the maximum possible power of 2 exponent + /// for a significand bounded by 1 ≤ x < 2 (i.e. the IEEE definition). /// - /// If <i>x</i> = `MAX_EXP`, then normal numbers - /// < 1 × 2<sup><i>x</i></sup>. + /// This corresponds to the exact maximum possible power of 2 exponent + /// for a significand bounded by 0.5 ≤ x < 1 (i.e. the C definition). + /// In other words, all numbers representable by this type are + /// strictly less than 2<sup><i>MAX_EXP</i></sup>. #[unstable(feature = "f128", issue = "116909")] pub const MAX_EXP: i32 = 16_384; diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index ced5b51d262..afed6f04059 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -192,16 +192,22 @@ impl f16 { #[unstable(feature = "f16", issue = "116909")] pub const MAX: f16 = 6.5504e+4_f16; - /// One greater than the minimum possible normal power of 2 exponent. + /// One greater than the minimum possible *normal* power of 2 exponent + /// for a significand bounded by 1 ≤ x < 2 (i.e. the IEEE definition). /// - /// If <i>x</i> = `MIN_EXP`, then normal numbers - /// ≥ 0.5 × 2<sup><i>x</i></sup>. + /// This corresponds to the exact minimum possible *normal* power of 2 exponent + /// for a significand bounded by 0.5 ≤ x < 1 (i.e. the C definition). + /// In other words, all normal numbers representable by this type are + /// greater than or equal to 0.5 × 2<sup><i>MIN_EXP</i></sup>. #[unstable(feature = "f16", issue = "116909")] pub const MIN_EXP: i32 = -13; - /// Maximum possible power of 2 exponent. + /// One greater than the maximum possible power of 2 exponent + /// for a significand bounded by 1 ≤ x < 2 (i.e. the IEEE definition). /// - /// If <i>x</i> = `MAX_EXP`, then normal numbers - /// < 1 × 2<sup><i>x</i></sup>. + /// This corresponds to the exact maximum possible power of 2 exponent + /// for a significand bounded by 0.5 ≤ x < 1 (i.e. the C definition). + /// In other words, all numbers representable by this type are + /// strictly less than 2<sup><i>MAX_EXP</i></sup>. #[unstable(feature = "f16", issue = "116909")] pub const MAX_EXP: i32 = 16; diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index 84b0128bb69..44d87f3c93a 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -443,16 +443,22 @@ impl f32 { #[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. + /// One greater than the minimum possible *normal* power of 2 exponent + /// for a significand bounded by 1 ≤ x < 2 (i.e. the IEEE definition). /// - /// If <i>x</i> = `MIN_EXP`, then normal numbers - /// ≥ 0.5 × 2<sup><i>x</i></sup>. + /// This corresponds to the exact minimum possible *normal* power of 2 exponent + /// for a significand bounded by 0.5 ≤ x < 1 (i.e. the C definition). + /// In other words, all normal numbers representable by this type are + /// greater than or equal to 0.5 × 2<sup><i>MIN_EXP</i></sup>. #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MIN_EXP: i32 = -125; - /// Maximum possible power of 2 exponent. + /// One greater than the maximum possible power of 2 exponent + /// for a significand bounded by 1 ≤ x < 2 (i.e. the IEEE definition). /// - /// If <i>x</i> = `MAX_EXP`, then normal numbers - /// < 1 × 2<sup><i>x</i></sup>. + /// This corresponds to the exact maximum possible power of 2 exponent + /// for a significand bounded by 0.5 ≤ x < 1 (i.e. the C definition). + /// In other words, all numbers representable by this type are + /// strictly less than 2<sup><i>MAX_EXP</i></sup>. #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MAX_EXP: i32 = 128; diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index 2197e804aa8..e90af8774e4 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -442,16 +442,22 @@ impl f64 { #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MAX: f64 = 1.7976931348623157e+308_f64; - /// One greater than the minimum possible normal power of 2 exponent. + /// One greater than the minimum possible *normal* power of 2 exponent + /// for a significand bounded by 1 ≤ x < 2 (i.e. the IEEE definition). /// - /// If <i>x</i> = `MIN_EXP`, then normal numbers - /// ≥ 0.5 × 2<sup><i>x</i></sup>. + /// This corresponds to the exact minimum possible *normal* power of 2 exponent + /// for a significand bounded by 0.5 ≤ x < 1 (i.e. the C definition). + /// In other words, all normal numbers representable by this type are + /// greater than or equal to 0.5 × 2<sup><i>MIN_EXP</i></sup>. #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MIN_EXP: i32 = -1021; - /// Maximum possible power of 2 exponent. + /// One greater than the maximum possible power of 2 exponent + /// for a significand bounded by 1 ≤ x < 2 (i.e. the IEEE definition). /// - /// If <i>x</i> = `MAX_EXP`, then normal numbers - /// < 1 × 2<sup><i>x</i></sup>. + /// This corresponds to the exact maximum possible power of 2 exponent + /// for a significand bounded by 0.5 ≤ x < 1 (i.e. the C definition). + /// In other words, all numbers representable by this type are + /// strictly less than 2<sup><i>MAX_EXP</i></sup>. #[stable(feature = "assoc_int_consts", since = "1.43.0")] pub const MAX_EXP: i32 = 1024; |
