On Friday 17 September 2004 14:28, Andrea Arcangeli wrote: > I also wonder if a O(1) algorithm exists to roundup to the next power of > two (doesn't come to mind by memory, hmm maybe it's not that easy > problem). Assuming that the architecture has an O(1) fls() function, this should work for non-zero values: inline unsigned int roundup(unsigned int x) { return (1 << fls(x)); } -Ryan