Thursday, October 3, 2013

Getting the next multiple of 4

To get the integer which is the next multiple of 4:

(x+3) &~0x03

If x is a multiple of 4, it will give x itself, otherwise the closest integer greater than x which is a multiple of 4.

No comments:

Post a Comment