Export (0) Print
Expand All

2.1.4.5 BlockAlign -- Macro to Round a Value Up to the Next Nearest Multiple of Another Value

The inputs for this algorithm are:

  • Value: The value being rounded up.

  • Boundary - Value is to be rounded up to a multiple of this value. Boundary MUST be a power of 2.

This algorithm returns the bitwise AND of (Value + (Boundary - 1)) with the 2's complement of Boundary.

Pseudocode for the algorithm is as follows:

  • BlockAlign(Value, Boundary) = (Value + (Boundary - 1)) & -(Boundary)

 
Show:
© 2014 Microsoft