| ... | @@ -548,8 +548,8 @@ pub fn rotr(comptime T: type, x: T, r: anytype) T { | ... | @@ -548,8 +548,8 @@ pub fn rotr(comptime T: type, x: T, r: anytype) T { |
| 548 | } else if (@typeInfo(T).Int.signedness == .signed) { | 548 | } else if (@typeInfo(T).Int.signedness == .signed) { |
| 549 | @compileError("cannot rotate signed integer"); | 549 | @compileError("cannot rotate signed integer"); |
| 550 | } else { | 550 | } else { |
| 551 | const ar = @mod(r, @typeInfo(T).Int.bits); | 551 | const ar = @intCast(Log2Int(T), @mod(r, @typeInfo(T).Int.bits)); |
| 552 | return shr(T, x, ar) | shl(T, x, @typeInfo(T).Int.bits - ar); | 552 | return x >> ar | x << (1 +% ~ar); |
| 553 | } | 553 | } |
| 554 | } | 554 | } |
| 555 | | 555 | |
| ... | @@ -576,8 +576,8 @@ pub fn rotl(comptime T: type, x: T, r: anytype) T { | ... | @@ -576,8 +576,8 @@ pub fn rotl(comptime T: type, x: T, r: anytype) T { |
| 576 | } else if (@typeInfo(T).Int.signedness == .signed) { | 576 | } else if (@typeInfo(T).Int.signedness == .signed) { |
| 577 | @compileError("cannot rotate signed integer"); | 577 | @compileError("cannot rotate signed integer"); |
| 578 | } else { | 578 | } else { |
| 579 | const ar = @mod(r, @typeInfo(T).Int.bits); | 579 | const ar = @intCast(Log2Int(T), @mod(r, @typeInfo(T).Int.bits)); |
| 580 | return shl(T, x, ar) | shr(T, x, @typeInfo(T).Int.bits - ar); | 580 | return x << ar | x >> 1 +% ~ar; |
| 581 | } | 581 | } |
| 582 | } | 582 | } |
| 583 | | 583 | |