diff --git a/Sources/IntegerUtilities/GCD.swift b/Sources/IntegerUtilities/GCD.swift index 3e6afdf..8b3d519 100644 --- a/Sources/IntegerUtilities/GCD.swift +++ b/Sources/IntegerUtilities/GCD.swift @@ -14,6 +14,13 @@ /// If both inputs are zero, the result is zero. If one input is zero, the /// result is the absolute value of the other input. /// +/// The resulting value must be representable within the value's type. In +/// particular, the gcd of a signed, fixed-width integer type's minimum +/// with itself or zero results in a value that cannot be represented: +/// +/// gcd(Int.min, Int.min) // Overflow error +/// gcd(Int.min, 0) // Overflow error +/// /// [wiki]: https://en.wikipedia.org/wiki/Greatest_common_divisor @inlinable public func gcd(_ a: T, _ b: T) -> T {