@Sandy: You could use this when you need to round up a number to a number that has a certain number of low-order zeros. As far as a practical application: when you need it you need it.
Dave On Sep 6, 10:31 am, Sandy <sandy.wad...@gmail.com> wrote: > What is the practical application of this expression? > > > > > > On Tue, Sep 6, 2011 at 5:38 PM, Dave <dave_and_da...@juno.com> wrote: > > @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. > > -- > > *Sandeep Kumar,* > ( Mobile +91-9866507368 > > *“I believe in smart work, Believe Me”*- Hide quoted text - > > - Show quoted text - -- 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.