mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Rollup merge of #140149 - RalfJung:test_nan, r=tgross35
test_nan: ensure the NAN contant is quiet Follow-up to https://github.com/rust-lang/rust/pull/139483 r? ``@tgross35``
This commit is contained in:
commit
2d8264fb08
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user