Skip to content

Commit fc36653

Browse files
committed
Minvalue causes crash.
1 parent e988da6 commit fc36653

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/std/math/egcd.zig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ pub fn egcd(a: anytype, b: anytype) ExtendedGreatestCommonDivisor(@TypeOf(a, b))
106106
}
107107

108108
test {
109+
{
110+
const a: i16 = -32768;
111+
const b: i16 = -32768;
112+
const r = egcd(a, b);
113+
const g = r.gcd;
114+
const s: i32 = r.bezout_coeff_1;
115+
const t: i32 = r.bezout_coeff_2;
116+
try std.testing.expect(s * a + t * b == g);
117+
}
109118
{
110119
const a: i32 = 128;
111120
const b: i32 = 112;

0 commit comments

Comments
 (0)