Skip to content

Commit c5fe405

Browse files
committed
Clarify distinction between floor() and trunc()
1 parent 190feb6 commit c5fe405

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/libstd/f32.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ impl f32 {
3232
/// # Examples
3333
///
3434
/// ```
35-
/// let f = 3.99_f32;
35+
/// let f = 3.7_f32;
3636
/// let g = 3.0_f32;
37+
/// let h = -3.7_f32;
3738
///
3839
/// assert_eq!(f.floor(), 3.0);
3940
/// assert_eq!(g.floor(), 3.0);
41+
/// assert_eq!(h.floor(), -4.0);
4042
/// ```
4143
#[stable(feature = "rust1", since = "1.0.0")]
4244
#[inline]
@@ -104,11 +106,13 @@ impl f32 {
104106
/// # Examples
105107
///
106108
/// ```
107-
/// let f = 3.3_f32;
108-
/// let g = -3.7_f32;
109+
/// let f = 3.7_f32;
110+
/// let g = 3.0_f32;
111+
/// let h = -3.7_f32;
109112
///
110113
/// assert_eq!(f.trunc(), 3.0);
111-
/// assert_eq!(g.trunc(), -3.0);
114+
/// assert_eq!(g.trunc(), 3.0);
115+
/// assert_eq!(h.trunc(), -3.0);
112116
/// ```
113117
#[stable(feature = "rust1", since = "1.0.0")]
114118
#[inline]

src/libstd/f64.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ impl f64 {
3232
/// # Examples
3333
///
3434
/// ```
35-
/// let f = 3.99_f64;
35+
/// let f = 3.7_f64;
3636
/// let g = 3.0_f64;
37+
/// let h = -3.7_f64;
3738
///
3839
/// assert_eq!(f.floor(), 3.0);
3940
/// assert_eq!(g.floor(), 3.0);
41+
/// assert_eq!(h.floor(), -4.0);
4042
/// ```
4143
#[stable(feature = "rust1", since = "1.0.0")]
4244
#[inline]
@@ -84,11 +86,13 @@ impl f64 {
8486
/// # Examples
8587
///
8688
/// ```
87-
/// let f = 3.3_f64;
88-
/// let g = -3.7_f64;
89+
/// let f = 3.7_f64;
90+
/// let g = 3.0_f64;
91+
/// let h = -3.7_f64;
8992
///
9093
/// assert_eq!(f.trunc(), 3.0);
91-
/// assert_eq!(g.trunc(), -3.0);
94+
/// assert_eq!(g.trunc(), 3.0);
95+
/// assert_eq!(h.trunc(), -3.0);
9296
/// ```
9397
#[stable(feature = "rust1", since = "1.0.0")]
9498
#[inline]

0 commit comments

Comments
 (0)