Does anyone know an inexpensive algorithm (O(1)) to go from an number to
the next (lower or higher) power of two.

1                       -> 1
2,3                     -> 2
4,5,6,7                 -> 4
8,9,10,11,12,13,14,15   -> 8
etc.

So %1101 should become either %10000 or %1000.

The only solution I have so far is a table. That is a possibility as the
the highest number will be 32 I think.

Nick

-- 
e-Mail: hi...@skylink.it



To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to