aboutsummaryrefslogtreecommitdiff
path: root/ctr-std/src/f64.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ctr-std/src/f64.rs')
-rw-r--r--ctr-std/src/f64.rs11
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")]