diff --git a/src/padding.zig b/src/padding.zig index 66ff91e..df8017c 100644 --- a/src/padding.zig +++ b/src/padding.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const assert = std.debug.assert; // rounds up a u12 to the nearest factor of 4 and returns the difference // (padding) @@ -8,6 +9,7 @@ pub fn roundUpPadding(comptime T: type, comptime nbits: u8, n: T) T { // rounds up a u12 to the nearest factor of 4. pub fn roundUp(comptime T: type, comptime nbits: u8, n: T) T { + comptime assert(nbits < @bitSizeOf(T)); const factor = comptime (1 << nbits) - 1; return ((n + factor) & ~@as(T, factor)); }