Skip to content

Commit 7a8397f

Browse files
Merge #50
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 <[email protected]>
2 parents d5267dc + bba8f3d commit 7a8397f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ pub fn div_ceil<T: Integer>(x: T, y: T) -> T {
386386
}
387387

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

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

0 commit comments

Comments
 (0)