-
Notifications
You must be signed in to change notification settings - Fork 13.3k
deprecate f{32,64}::DIGITS #89238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deprecate f{32,64}::DIGITS #89238
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,21 +54,28 @@ pub const RADIX: u32 = f32::RADIX; | |
)] | ||
pub const MANTISSA_DIGITS: u32 = f32::MANTISSA_DIGITS; | ||
|
||
/// Approximate number of significant digits in base 10. | ||
/// Use [`f32::DIGITS`] instead. | ||
/// A minimum number of significant digits in base 10. | ||
/// This value is likely incorrect for usage, | ||
/// as it is not the upper limit of significant digits `f32` can contain. | ||
/// | ||
/// # Examples | ||
/// | ||
/// ```rust | ||
/// // deprecated way | ||
/// # #[allow(deprecated, deprecated_in_future)] | ||
/// let d = std::f32::DIGITS; | ||
/// | ||
/// // intended way | ||
/// // also deprecated | ||
/// # #[allow(deprecated, deprecated_in_future)] | ||
/// let d = f32::DIGITS; | ||
/// | ||
/// // the intended way may vary by application | ||
/// ``` | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
#[rustc_deprecated(since = "TBD", reason = "replaced by the `DIGITS` associated constant on `f32`")] | ||
#[rustc_deprecated( | ||
since = "TBD", | ||
reason = "this value is incorrect or misleading as it actually encompasses a range" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really tiny nit, but I feel like the word 'encompasses' is misleading here. I might read that and think that the deprecated value is the upper bound, and therefore safe. |
||
)] | ||
#[allow(deprecated, deprecated_in_future)] | ||
pub const DIGITS: u32 = f32::DIGITS; | ||
|
||
/// [Machine epsilon] value for `f32`. | ||
|
@@ -381,8 +388,14 @@ impl f32 { | |
#[stable(feature = "assoc_int_consts", since = "1.43.0")] | ||
pub const MANTISSA_DIGITS: u32 = 24; | ||
|
||
/// Approximate number of significant digits in base 10. | ||
/// A minimum number of significant digits in base 10. | ||
/// This value is likely incorrect for usage, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here as well |
||
/// as it is not the upper limit of significant digits `f32` can contain. | ||
#[stable(feature = "assoc_int_consts", since = "1.43.0")] | ||
#[rustc_deprecated( | ||
since = "TBD", | ||
reason = "this value is incorrect or misleading as it actually encompasses a range" | ||
)] | ||
pub const DIGITS: u32 = 6; | ||
|
||
/// [Machine epsilon] value for `f32`. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,21 +54,28 @@ pub const RADIX: u32 = f64::RADIX; | |
)] | ||
pub const MANTISSA_DIGITS: u32 = f64::MANTISSA_DIGITS; | ||
|
||
/// Approximate number of significant digits in base 10. | ||
/// Use [`f64::DIGITS`] instead. | ||
/// A minimum number of significant digits in base 10. | ||
/// This value is likely incorrect for usage, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here too |
||
/// as it is not the upper limit of significant digits `f64` can contain. | ||
/// | ||
/// # Examples | ||
/// | ||
/// ```rust | ||
/// // deprecated way | ||
/// # #[allow(deprecated, deprecated_in_future)] | ||
/// let d = std::f64::DIGITS; | ||
/// | ||
/// // intended way | ||
/// // also deprecated | ||
/// # #[allow(deprecated, deprecated_in_future)] | ||
/// let d = f64::DIGITS; | ||
/// | ||
/// // the intended way may vary by application | ||
/// ``` | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
#[rustc_deprecated(since = "TBD", reason = "replaced by the `DIGITS` associated constant on `f64`")] | ||
#[rustc_deprecated( | ||
since = "TBD", | ||
reason = "this value is incorrect or misleading as it actually encompasses a range" | ||
)] | ||
#[allow(deprecated, deprecated_in_future)] | ||
pub const DIGITS: u32 = f64::DIGITS; | ||
|
||
/// [Machine epsilon] value for `f64`. | ||
|
@@ -380,8 +387,15 @@ impl f64 { | |
/// Number of significant digits in base 2. | ||
#[stable(feature = "assoc_int_consts", since = "1.43.0")] | ||
pub const MANTISSA_DIGITS: u32 = 53; | ||
/// Approximate number of significant digits in base 10. | ||
|
||
/// A minimum number of significant digits in base 10. | ||
/// This value is likely incorrect for usage, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here |
||
/// as it is not the upper limit of significant digits `f64` can contain. | ||
#[stable(feature = "assoc_int_consts", since = "1.43.0")] | ||
#[rustc_deprecated( | ||
since = "TBD", | ||
reason = "this value is incorrect or misleading as it actually encompasses a range" | ||
)] | ||
pub const DIGITS: u32 = 15; | ||
|
||
/// [Machine epsilon] value for `f64`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just need to elaborate on this and add a small example of how this can be incorrect.