diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-03-19 15:16:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-19 15:16:50 +0100 |
| commit | 5abd9c7d15d5e3a82a4bfc978ea7618bba1b9e12 (patch) | |
| tree | 70b61f1a4d599c2f11ee28357885f84fbc4f9e20 | |
| parent | fff8586193ea9ee75078aebb57205943e4312691 (diff) | |
| parent | c5fe4055a90d0dac5dc80178d58148c042c5de2b (diff) | |
| download | rust-5abd9c7d15d5e3a82a4bfc978ea7618bba1b9e12.tar.gz rust-5abd9c7d15d5e3a82a4bfc978ea7618bba1b9e12.zip | |
Rollup merge of #58812 - jonhoo:floor_v_trunc, r=alexcrichton
Clarify distinction between floor() and trunc() `floor()` rounds towards `-INF`, `trunc()` rounds towards 0. This PR clarifies this in the examples.
| -rw-r--r-- | src/libstd/f32.rs | 12 | ||||
| -rw-r--r-- | src/libstd/f64.rs | 12 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index a2b12d00a78..2fabe30fa93 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -32,11 +32,13 @@ impl f32 { /// # Examples /// /// ``` - /// let f = 3.99_f32; + /// let f = 3.7_f32; /// let g = 3.0_f32; + /// let h = -3.7_f32; /// /// assert_eq!(f.floor(), 3.0); /// assert_eq!(g.floor(), 3.0); + /// assert_eq!(h.floor(), -4.0); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -104,11 +106,13 @@ impl f32 { /// # Examples /// /// ``` - /// let f = 3.3_f32; - /// let g = -3.7_f32; + /// let f = 3.7_f32; + /// let g = 3.0_f32; + /// let h = -3.7_f32; /// /// assert_eq!(f.trunc(), 3.0); - /// assert_eq!(g.trunc(), -3.0); + /// assert_eq!(g.trunc(), 3.0); + /// assert_eq!(h.trunc(), -3.0); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index be5cd92d416..a471117f6d6 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -32,11 +32,13 @@ impl f64 { /// # Examples /// /// ``` - /// let f = 3.99_f64; + /// let f = 3.7_f64; /// let g = 3.0_f64; + /// let h = -3.7_f64; /// /// assert_eq!(f.floor(), 3.0); /// assert_eq!(g.floor(), 3.0); + /// assert_eq!(h.floor(), -4.0); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -84,11 +86,13 @@ impl f64 { /// # Examples /// /// ``` - /// let f = 3.3_f64; - /// let g = -3.7_f64; + /// let f = 3.7_f64; + /// let g = 3.0_f64; + /// let h = -3.7_f64; /// /// assert_eq!(f.trunc(), 3.0); - /// assert_eq!(g.trunc(), -3.0); + /// assert_eq!(g.trunc(), 3.0); + /// assert_eq!(h.trunc(), -3.0); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] |
