Skip to content

Commit daeadc6

Browse files
author
Fabian Kössel
committed
Clarify rational behind current implementation of .mod_euc()
1 parent af6f0f2 commit daeadc6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/libstd/f32.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ impl f32 {
258258
/// most cases. However, due to a floating point round-off error it can
259259
/// result in `r == rhs.abs()`, violating the mathematical definition, if
260260
/// `self` is much smaller than `rhs.abs()` in magnitude and `self < 0.0`.
261+
/// This result is not an element of the function's codomain, but it is the
262+
/// closest floating point number in the real numbers and thus fulfills the
263+
/// property `self == self.div_euc(rhs) * rhs + self.mod_euc(rhs)`
264+
/// approximatively.
261265
///
262266
/// # Examples
263267
///

src/libstd/f64.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ impl f64 {
234234
/// most cases. However, due to a floating point round-off error it can
235235
/// result in `r == rhs.abs()`, violating the mathematical definition, if
236236
/// `self` is much smaller than `rhs.abs()` in magnitude and `self < 0.0`.
237+
/// This result is not an element of the function's codomain, but it is the
238+
/// closest floating point number in the real numbers and thus fulfills the
239+
/// property `self == self.div_euc(rhs) * rhs + self.mod_euc(rhs)`
240+
/// approximatively.
237241
///
238242
/// # Examples
239243
///

0 commit comments

Comments
 (0)