about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/core/src/num/f128.rs3
-rw-r--r--library/core/src/num/f16.rs3
-rw-r--r--library/core/src/num/f32.rs3
-rw-r--r--library/core/src/num/f64.rs3
-rw-r--r--library/std/tests/floats/f128.rs2
-rw-r--r--library/std/tests/floats/f16.rs2
-rw-r--r--library/std/tests/floats/f32.rs2
-rw-r--r--library/std/tests/floats/f64.rs2
8 files changed, 20 insertions, 0 deletions
diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs
index d3d1eebc227..2ee25969289 100644
--- a/library/core/src/num/f128.rs
+++ b/library/core/src/num/f128.rs
@@ -145,6 +145,9 @@ impl f128 {
     pub const RADIX: u32 = 2;
 
     /// Number of significant digits in base 2.
+    ///
+    /// Note that the size of the mantissa in the bitwise representation is one
+    /// smaller than this since the leading 1 is not stored explicitly.
     #[unstable(feature = "f128", issue = "116909")]
     pub const MANTISSA_DIGITS: u32 = 113;
 
diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs
index dceb30177e6..69882d13c17 100644
--- a/library/core/src/num/f16.rs
+++ b/library/core/src/num/f16.rs
@@ -140,6 +140,9 @@ impl f16 {
     pub const RADIX: u32 = 2;
 
     /// Number of significant digits in base 2.
+    ///
+    /// Note that the size of the mantissa in the bitwise representation is one
+    /// smaller than this since the leading 1 is not stored explicitly.
     #[unstable(feature = "f16", issue = "116909")]
     pub const MANTISSA_DIGITS: u32 = 11;
 
diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs
index c97dbfb63ae..7e056a6c1f3 100644
--- a/library/core/src/num/f32.rs
+++ b/library/core/src/num/f32.rs
@@ -390,6 +390,9 @@ impl f32 {
     pub const RADIX: u32 = 2;
 
     /// Number of significant digits in base 2.
+    ///
+    /// Note that the size of the mantissa in the bitwise representation is one
+    /// smaller than this since the leading 1 is not stored explicitly.
     #[stable(feature = "assoc_int_consts", since = "1.43.0")]
     pub const MANTISSA_DIGITS: u32 = 24;
 
diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs
index 91affdb3794..b9ebbb1d764 100644
--- a/library/core/src/num/f64.rs
+++ b/library/core/src/num/f64.rs
@@ -390,6 +390,9 @@ impl f64 {
     pub const RADIX: u32 = 2;
 
     /// Number of significant digits in base 2.
+    ///
+    /// Note that the size of the mantissa in the bitwise representation is one
+    /// smaller than this since the leading 1 is not stored explicitly.
     #[stable(feature = "assoc_int_consts", since = "1.43.0")]
     pub const MANTISSA_DIGITS: u32 = 53;
     /// Approximate number of significant digits in base 10.
diff --git a/library/std/tests/floats/f128.rs b/library/std/tests/floats/f128.rs
index df28e8129dd..677738bac8f 100644
--- a/library/std/tests/floats/f128.rs
+++ b/library/std/tests/floats/f128.rs
@@ -112,6 +112,8 @@ fn test_nan() {
     assert!(!nan.is_sign_negative());
     assert!(!nan.is_normal());
     assert_eq!(Fp::Nan, nan.classify());
+    // Ensure the quiet bit is set.
+    assert!(nan.to_bits() & (1 << (f128::MANTISSA_DIGITS - 2)) != 0);
 }
 
 #[test]
diff --git a/library/std/tests/floats/f16.rs b/library/std/tests/floats/f16.rs
index 1a90f00aecc..0fc4df8115a 100644
--- a/library/std/tests/floats/f16.rs
+++ b/library/std/tests/floats/f16.rs
@@ -95,6 +95,8 @@ fn test_nan() {
     assert!(!nan.is_sign_negative());
     assert!(!nan.is_normal());
     assert_eq!(Fp::Nan, nan.classify());
+    // Ensure the quiet bit is set.
+    assert!(nan.to_bits() & (1 << (f16::MANTISSA_DIGITS - 2)) != 0);
 }
 
 #[test]
diff --git a/library/std/tests/floats/f32.rs b/library/std/tests/floats/f32.rs
index d99b03cb255..9af23afc5bb 100644
--- a/library/std/tests/floats/f32.rs
+++ b/library/std/tests/floats/f32.rs
@@ -72,6 +72,8 @@ fn test_nan() {
     assert!(nan.is_sign_positive());
     assert!(!nan.is_sign_negative());
     assert_eq!(Fp::Nan, nan.classify());
+    // Ensure the quiet bit is set.
+    assert!(nan.to_bits() & (1 << (f32::MANTISSA_DIGITS - 2)) != 0);
 }
 
 #[test]
diff --git a/library/std/tests/floats/f64.rs b/library/std/tests/floats/f64.rs
index 611670751bb..de9c27eb33d 100644
--- a/library/std/tests/floats/f64.rs
+++ b/library/std/tests/floats/f64.rs
@@ -60,6 +60,8 @@ fn test_nan() {
     assert!(nan.is_sign_positive());
     assert!(!nan.is_sign_negative());
     assert_eq!(Fp::Nan, nan.classify());
+    // Ensure the quiet bit is set.
+    assert!(nan.to_bits() & (1 << (f64::MANTISSA_DIGITS - 2)) != 0);
 }
 
 #[test]