Documented overflow behavior of gcd

This commit is contained in:
NevinBR authored and GitHub committed 2021-08-31 11:19:22 -04:00
1 parent 89c4e42e48
commit 8552becf91
1 file changed
+7
+7
View File
@@ -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<T: BinaryInteger>(_ a: T, _ b: T) -> T {