@Mohit: If n is a power of 2, then the macro returns x if x is a multiple of n or x rounded up to the next multiple of n if x is not a multiple of n. E.g., ROUNDUP(16,4) = 16 and ROUNDUP(17,4) = 20. The result doesn't appear useful if n is not a power of 2.
Since ~(n-1) = -n, it could be written more compactly as #define ROUNDUP(x,n) ((x+n-1)&(-(n))) Dave On Sep 6, 5:06 am, Mohit Goel <mohitgoel291...@gmail.com> wrote: > #define ROUNDUP(x,n) ((x+n-1)&(~(n-1))) > > what does the following macro do .... -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.