We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8fe1087 commit ea369cbCopy full SHA for ea369cb
src/libcore/ops/arith.rs
@@ -540,7 +540,17 @@ macro_rules! rem_impl_float {
540
541
/// The remainder from the division of two floats.
542
///
543
- /// The remainder has the same sign as the dividend. For example: `-5.0 % 2.0 = -1.0`.
+ /// The remainder has the same sign as the dividend and is computed as:
544
+ /// `x - (x / y).trunc() * y`.
545
+ ///
546
+ /// # Examples
547
+ /// ```
548
+ /// let x: f32 = 4.0;
549
+ /// let y: f32 = 2.5;
550
+ /// let remainder = x - (x / y).trunc() * y;
551
552
+ /// assert_eq!(x % y, remainder);
553
554
#[stable(feature = "rust1", since = "1.0.0")]
555
impl Rem for $t {
556
type Output = $t;
0 commit comments