From bba8f3d6b344be6d5e8bc6d5d7c7a164df482c38 Mon Sep 17 00:00:00 2001 From: Paul Crowley Date: Wed, 16 Mar 2022 07:12:24 -0700 Subject: [PATCH] Correct documentation for gcd `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) --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9d55722..c63ecfd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -386,7 +386,7 @@ pub fn div_ceil(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(x: T, y: T) -> T { x.gcd(&y) @@ -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