mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 21:15:18 +03:00
Rollup merge of #156392 - Wilfred:float_ceil_docs, r=Mark-Simulacrum
Improve doc comments for f32::ceil() and f32::floor() Previously ::floor() included an example showing behaviour for negative values, but ::ceil() did not. Ensure both have examples of the negative case, for both f32 and f64. Whilst we're here, tweak the wording slightly so it reads better.
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
|
||||
#[cfg(not(test))]
|
||||
impl f32 {
|
||||
/// Returns the largest integer less than or equal to `self`.
|
||||
/// Returns the largest integer that is less than or equal to `self`.
|
||||
///
|
||||
/// This function always returns the precise result.
|
||||
///
|
||||
@@ -50,7 +50,7 @@ pub const fn floor(self) -> f32 {
|
||||
core::f32::math::floor(self)
|
||||
}
|
||||
|
||||
/// Returns the smallest integer greater than or equal to `self`.
|
||||
/// Returns the smallest integer that is greater than or equal to `self`.
|
||||
///
|
||||
/// This function always returns the precise result.
|
||||
///
|
||||
@@ -59,9 +59,11 @@ pub const fn floor(self) -> f32 {
|
||||
/// ```
|
||||
/// let f = 3.01_f32;
|
||||
/// let g = 4.0_f32;
|
||||
/// let h = -3.01_f32;
|
||||
///
|
||||
/// assert_eq!(f.ceil(), 4.0);
|
||||
/// assert_eq!(g.ceil(), 4.0);
|
||||
/// assert_eq!(h.ceil(), -3.0);
|
||||
/// ```
|
||||
#[doc(alias = "ceiling")]
|
||||
#[rustc_allow_incoherent_impl]
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#[cfg(not(test))]
|
||||
impl f64 {
|
||||
/// Returns the largest integer less than or equal to `self`.
|
||||
/// Returns the largest integer that is less than or equal to `self`.
|
||||
///
|
||||
/// This function always returns the precise result.
|
||||
///
|
||||
@@ -50,7 +50,7 @@ pub const fn floor(self) -> f64 {
|
||||
core::f64::math::floor(self)
|
||||
}
|
||||
|
||||
/// Returns the smallest integer greater than or equal to `self`.
|
||||
/// Returns the smallest integer that is greater than or equal to `self`.
|
||||
///
|
||||
/// This function always returns the precise result.
|
||||
///
|
||||
@@ -59,9 +59,11 @@ pub const fn floor(self) -> f64 {
|
||||
/// ```
|
||||
/// let f = 3.01_f64;
|
||||
/// let g = 4.0_f64;
|
||||
/// let h = -3.01_f64;
|
||||
///
|
||||
/// assert_eq!(f.ceil(), 4.0);
|
||||
/// assert_eq!(g.ceil(), 4.0);
|
||||
/// assert_eq!(h.ceil(), -3.0);
|
||||
/// ```
|
||||
#[doc(alias = "ceiling")]
|
||||
#[rustc_allow_incoherent_impl]
|
||||
|
||||
Reference in New Issue
Block a user