Skip to content

Commit 16cf4b0

Browse files
committed
Simplify half_ctlr
1 parent bb4def6 commit 16cf4b0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/std/math/egcd.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ pub fn egcd(a: anytype, b: anytype) ExtendedGreatestCommonDivisor(@TypeOf(a, b))
4040
};
4141
const toinv = @shrExact(other, @intCast(shift));
4242
const ctrl = @shrExact(odd, @intCast(shift)); // Invariant: |s|, |t|, |ctrl| < |MIN_OF(S)|
43-
const half_ctrl = 1 + @shrExact(ctrl - 1, 1);
4443
const abs_ctrl = @abs(ctrl);
44+
const half_ctrl: S = @intCast(1 + abs_ctrl >> 1);
4545

4646
var s: S = std.math.sign(toinv);
4747
var t: S = 0;

0 commit comments

Comments
 (0)