Skip to content

Commit

Permalink
Merge #50
Browse files Browse the repository at this point in the history
50: Correct documentation for gcd r=cuviper a=ciphergoth

`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)

Co-authored-by: Paul Crowley <github@paul.ciphergoth.org>
  • Loading branch information
bors[bot] and ciphergoth committed Mar 21, 2022
2 parents d5267dc + bba8f3d commit 7a8397f
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 7a8397f

Please sign in to comment.