diff options
| author | bors <bors@rust-lang.org> | 2018-06-27 23:41:23 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-06-27 23:41:23 +0000 |
| commit | 266afeb17c993f83d01d8129e97981a57bb442e0 (patch) | |
| tree | 9674856da47b18f31a9b7918ce89a6e6163f43c7 /src/libstd | |
| parent | cd494c1f0915da00a63c03454a96d504afe764ff (diff) | |
| parent | 99a0d6bf0e478f7ad0dd06ccf2c4d83da69d3167 (diff) | |
| download | rust-266afeb17c993f83d01d8129e97981a57bb442e0.tar.gz rust-266afeb17c993f83d01d8129e97981a57bb442e0.zip | |
Auto merge of #51859 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests Successful merges: - #49987 (Add str::split_ascii_whitespace.) - #50342 (Document round-off error in `.mod_euc()`-method, see issue #50179) - #51658 (Only do sanity check with debug assertions on) - #51799 (Lower case some feature gate error messages) - #51800 (Add a compiletest header for edition) - #51824 (Fix the error reference for LocalKey::try_with) - #51842 (Document that Layout::from_size_align does not allow align=0) Failed merges: r? @ghost
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/f32.rs | 11 | ||||
| -rw-r--r-- | src/libstd/f64.rs | 11 | ||||
| -rw-r--r-- | src/libstd/thread/local.rs | 2 |
3 files changed, 21 insertions, 3 deletions
diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index ae30321f46d..8e8340b3ed9 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -254,7 +254,14 @@ impl f32 { /// Calculates the Euclidean modulo (self mod rhs), which is never negative. /// - /// In particular, the result `n` satisfies `0 <= n < rhs.abs()`. + /// In particular, the return value `r` satisfies `0.0 <= r < rhs.abs()` in + /// most cases. However, due to a floating point round-off error it can + /// result in `r == rhs.abs()`, violating the mathematical definition, if + /// `self` is much smaller than `rhs.abs()` in magnitude and `self < 0.0`. + /// This result is not an element of the function's codomain, but it is the + /// closest floating point number in the real numbers and thus fulfills the + /// property `self == self.div_euc(rhs) * rhs + self.mod_euc(rhs)` + /// approximatively. /// /// # Examples /// @@ -266,6 +273,8 @@ impl f32 { /// assert_eq!((-a).mod_euc(b), 1.0); /// assert_eq!(a.mod_euc(-b), 3.0); /// assert_eq!((-a).mod_euc(-b), 1.0); + /// // limitation due to round-off error + /// assert!((-std::f32::EPSILON).mod_euc(3.0) != 0.0); /// ``` #[inline] #[unstable(feature = "euclidean_division", issue = "49048")] diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index 7950d434b77..6880294afca 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -230,7 +230,14 @@ impl f64 { /// Calculates the Euclidean modulo (self mod rhs), which is never negative. /// - /// In particular, the result `n` satisfies `0 <= n < rhs.abs()`. + /// In particular, the return value `r` satisfies `0.0 <= r < rhs.abs()` in + /// most cases. However, due to a floating point round-off error it can + /// result in `r == rhs.abs()`, violating the mathematical definition, if + /// `self` is much smaller than `rhs.abs()` in magnitude and `self < 0.0`. + /// This result is not an element of the function's codomain, but it is the + /// closest floating point number in the real numbers and thus fulfills the + /// property `self == self.div_euc(rhs) * rhs + self.mod_euc(rhs)` + /// approximatively. /// /// # Examples /// @@ -242,6 +249,8 @@ impl f64 { /// assert_eq!((-a).mod_euc(b), 1.0); /// assert_eq!(a.mod_euc(-b), 3.0); /// assert_eq!((-a).mod_euc(-b), 1.0); + /// // limitation due to round-off error + /// assert!((-std::f64::EPSILON).mod_euc(3.0) != 0.0); /// ``` #[inline] #[unstable(feature = "euclidean_division", issue = "49048")] diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 40d3280baa6..a170abb2628 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -276,7 +276,7 @@ impl<T: 'static> LocalKey<T> { /// /// This will lazily initialize the value if this thread has not referenced /// this key yet. If the key has been destroyed (which may happen if this is called - /// in a destructor), this function will return a `ThreadLocalError`. + /// in a destructor), this function will return an [`AccessError`](struct.AccessError.html). /// /// # Panics /// |
