Skip to content

Commit

Permalink
Correct documentation for gcd
Browse files Browse the repository at this point in the history
`gcd` asserts that the result is "always positive", but the result is (correctly) zero if both parameters are zero, so replace "positive" with "non-negative".

(Zero is correct here because 0Z + 0Z = 0Z where Z is the integers)
  • Loading branch information
ciphergoth committed Mar 16, 2022
1 parent d5267dc commit bba8f3d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Expand Up @@ -386,7 +386,7 @@ pub fn div_ceil<T: Integer>(x: T, y: T) -> T {
}

/// Calculates the Greatest Common Divisor (GCD) of the number and `other`. The
/// result is always positive.
/// result is always non-negative.
#[inline(always)]
pub fn gcd<T: Integer>(x: T, y: T) -> T {
x.gcd(&y)
Expand Down Expand Up @@ -457,7 +457,7 @@ macro_rules! impl_integer_for_isize {
}

/// Calculates the Greatest Common Divisor (GCD) of the number and
/// `other`. The result is always positive.
/// `other`. The result is always non-negative.
#[inline]
fn gcd(&self, other: &Self) -> Self {
// Use Stein's algorithm
Expand Down

0 comments on commit bba8f3d

Please sign in to comment.