What\'s a fast way to round up an unsigned int
to a multiple of 4
?
A multiple of 4 has the two least significant bits 0, right? So I could
This is branch-free, generally configurable, easy to understand (if you know about C byte strings), and it lets you avoid thinking about the bit size of myInt:
myInt += "\x00\x03\x02\x01"[myInt & 0x3];
Only downside is a possible single memory access to elsewhere (static string storage) than the stack.