| ... | @@ -366,7 +366,7 @@ test "math.shl" { | ... | @@ -366,7 +366,7 @@ test "math.shl" { |
| 366 | } | 366 | } |
| 367 | | 367 | |
| 368 | /// Shifts right. Overflowed bits are truncated. | 368 | /// Shifts right. Overflowed bits are truncated. |
| 369 | /// A negative shift amount results in a lefft shift. | 369 | /// A negative shift amount results in a left shift. |
| 370 | pub fn shr(comptime T: type, a: T, shift_amt: var) T { | 370 | pub fn shr(comptime T: type, a: T, shift_amt: var) T { |
| 371 | const abs_shift_amt = absCast(shift_amt); | 371 | const abs_shift_amt = absCast(shift_amt); |
| 372 | const casted_shift_amt = if (abs_shift_amt >= T.bit_count) return 0 else @intCast(Log2Int(T), abs_shift_amt); | 372 | const casted_shift_amt = if (abs_shift_amt >= T.bit_count) return 0 else @intCast(Log2Int(T), abs_shift_amt); |