> 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 ([EMAIL PROTECTED]) Realtime development, Machine control, HD Associates, Inc. Safety critical systems, Agency approval To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message
- Re: from number to power of two Patryk Zadarnowski
- Re: from number to power of two Johan Karlsson
- RE: from number to power of two Don Read
- Re: from number to power of two Warner Losh
- Re: from number to power of two John-Mark Gurney
- Re: from number to power of two Mark Murray
- Re: from number to power of two John-Mark Gurney
- Re: from number to power of two Daniel C. Sobral
- Re: from number to power of two Kazufumi-MIT-Mitani
- Re: from number to power of two Nick Hibma
- Re: from number to power of two Peter Dufault
- Re: from number to power of two Nick Hibma
- Re: from number to power of two Brian F. Feldman
- Re: from number to power of two Ollivier Robert
- Re: from number to power of two Peter Wemm
- Re: from number to power of two Tommy Hallgren
- Re: from number to power of two Bakul Shah