]> git.lizzy.rs Git - rust.git/commitdiff
Correct and clarify integer division rounding docs
authorWilliam Throwe <wtt6@cornell.edu>
Sun, 12 Jul 2015 00:30:50 +0000 (20:30 -0400)
committerWilliam Throwe <wtt6@cornell.edu>
Sun, 12 Jul 2015 00:30:50 +0000 (20:30 -0400)
src/libcore/num/mod.rs
src/libcore/ops.rs

index fd5ef4b1ccccaab3a384cf2b28e7047621f92776..c5423019d9464ffee544930df95ecd888115e780 100644 (file)
@@ -459,7 +459,7 @@ pub fn wrapping_mul(self, rhs: Self) -> Self {
             }
         }
 
-        /// Wrapping (modular) division. Computes `floor(self / other)`,
+        /// Wrapping (modular) division. Computes `self / other`,
         /// wrapping around at the boundary of the type.
         ///
         /// The only case where such wrapping can occur is when one
@@ -467,7 +467,7 @@ pub fn wrapping_mul(self, rhs: Self) -> Self {
         /// negative minimal value for the type); this is equivalent
         /// to `-MIN`, a positive value that is too large to represent
         /// in the type. In such a case, this function returns `MIN`
-        /// itself..
+        /// itself.
         #[stable(feature = "num_wrapping", since = "1.2.0")]
         #[inline(always)]
         pub fn wrapping_div(self, rhs: Self) -> Self {
@@ -1031,7 +1031,7 @@ pub fn wrapping_mul(self, rhs: Self) -> Self {
             }
         }
 
-        /// Wrapping (modular) division. Computes `floor(self / other)`,
+        /// Wrapping (modular) division. Computes `self / other`,
         /// wrapping around at the boundary of the type.
         ///
         /// The only case where such wrapping can occur is when one
@@ -1039,7 +1039,7 @@ pub fn wrapping_mul(self, rhs: Self) -> Self {
         /// negative minimal value for the type); this is equivalent
         /// to `-MIN`, a positive value that is too large to represent
         /// in the type. In such a case, this function returns `MIN`
-        /// itself..
+        /// itself.
         #[stable(feature = "num_wrapping", since = "1.2.0")]
         #[inline(always)]
         pub fn wrapping_div(self, rhs: Self) -> Self {
index 9a22fe3a493f12eba582c940e79833d5f2afd7c7..6f15a6bffa8a2da5d014415c19263bad4a11f860 100644 (file)
@@ -315,6 +315,9 @@ fn mul(self, other: $t) -> $t { self * other }
 
 /// The `Div` trait is used to specify the functionality of `/`.
 ///
+/// For primitive integral types, this operation rounds towards zero,
+/// truncating any fractional part of the exact result.
+///
 /// # Examples
 ///
 /// A trivial implementation of `Div`. When `Foo / Foo` happens, it ends up
@@ -369,6 +372,9 @@ fn div(self, other: $t) -> $t { self / other }
 
 /// The `Rem` trait is used to specify the functionality of `%`.
 ///
+/// For primitive integral types, this operation satisfies `n % d == n
+/// - (n / d) * d`.  The result has the same sign as the left operand.
+///
 /// # Examples
 ///
 /// A trivial implementation of `Rem`. When `Foo % Foo` happens, it ends up