in reply to Power of two round up.

1 << length(sprintf("%b", $input))

Not fast, of course, but perfectly fine when called only once such as for a new constant (or other inlineable subs)

use Some::Other::Module 'SOM_FLAGS_MAX'; use constant MY_FLAGS_MIN => (1<<length(sprintf("%b", SOM_FLAGS_MAX));