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 mask them out and then do a switch statement, adding either 1,2 or 3 to the given uint.
That’s not a very elegant solution..
There’s also the arithmetic roundup:
myint == 0 ? 0 : ((myint+3)/4)*4
Probably there’s a better way including some bit operations?
The addition of 3 is so that the next multiple of 4 becomes previous multiple of 4, which is produced by a modulo operation, doable by masking since the divisor is a power of 2.