> It seems that all the solutions are too generic and slow. As I only have > to check the numbers 0-32 (actually 1-32), a block of if statements is > almost as fast as a table look up in 33 elements.
I doubt it - use the table for a small fixed size set then use Warner's "(n) ? (1 << (ffs(n) - 1)) : 0". The possible inline ffs is in machine/cpufunc.h ffs() is fundamental to scheduling queues and cryptography and should have attention paid to it. As Warner said, it could be a single instruction on some architectures. Peter -- Peter Dufault (dufa...@hda.com) Realtime development, Machine control, HD Associates, Inc. Safety critical systems, Agency approval To Unsubscribe: send mail to majord...@freebsd.org with "unsubscribe freebsd-hackers" in the body of the message