C macro to find the next power of 2 ?
Jens Schweikhardt
schweikh at schweikhardt.net
Thu Feb 8 23:08:57 UTC 2007
Luigi,
...
#
# But i was wondering if there is some simpler code which
# can still be computed as a compile-time constant?
Is this requirement non-negotiable? Maybe in the days of C99
and run-time sized arrays it's worth thinking about other solutions
than CPP magic.
For this and other bit twiddling hacks in C (mostly functional), see
http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
Regards,
Jens
--
Jens Schweikhardt http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)
More information about the freebsd-current
mailing list