diff options
| author | FenrirWolf <[email protected]> | 2018-08-19 18:01:18 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-08-19 18:01:18 -0600 |
| commit | 15cb3c1e91842a68a8e50e1e1a42aefab13cc25e (patch) | |
| tree | a514fde042ff2a504a03305bfe0894ff8cd8d47e /ctr-std/src/f64.rs | |
| parent | Update for latest nightly 2018-06-09 (#70) (diff) | |
| parent | Update for nightly-2018-08-18 (diff) | |
| download | ctru-rs-15cb3c1e91842a68a8e50e1e1a42aefab13cc25e.tar.xz ctru-rs-15cb3c1e91842a68a8e50e1e1a42aefab13cc25e.zip | |
Merge pull request #73 from FenrirWolf/update-2018-08-18
Update for nightly-2018-08-18
Diffstat (limited to 'ctr-std/src/f64.rs')
| -rw-r--r-- | ctr-std/src/f64.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/ctr-std/src/f64.rs b/ctr-std/src/f64.rs index 7950d43..6880294 100644 --- a/ctr-std/src/f64.rs +++ b/ctr-std/src/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")] |