We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 89c4e42 commit 8552becCopy full SHA for 8552bec
Sources/IntegerUtilities/GCD.swift
@@ -14,6 +14,13 @@
14
/// If both inputs are zero, the result is zero. If one input is zero, the
15
/// result is the absolute value of the other input.
16
///
17
+/// The resulting value must be representable within the value's type. In
18
+/// particular, the gcd of a signed, fixed-width integer type's minimum
19
+/// with itself or zero results in a value that cannot be represented:
20
+///
21
+/// gcd(Int.min, Int.min) // Overflow error
22
+/// gcd(Int.min, 0) // Overflow error
23
24
/// [wiki]: https://en.wikipedia.org/wiki/Greatest_common_divisor
25
@inlinable
26
public func gcd<T: BinaryInteger>(_ a: T, _ b: T) -> T {
0 commit comments