Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Aug 1999 15:38:28 -0600
From:      Warner Losh <imp@village.org>
To:        Nick Hibma <hibma@skylink.it>
Cc:        FreeBSD Hackers mailing list <hackers@FreeBSD.ORG>
Subject:   Re: from number to power of two 
Message-ID:  <199908212138.PAA48856@harmony.village.org>
In-Reply-To: Your message of "Sat, 21 Aug 1999 12:54:32 %2B0200." <Pine.BSF.4.10.9908211250310.7595-100000@heidi.plazza.it> 
References:  <Pine.BSF.4.10.9908211250310.7595-100000@heidi.plazza.it>  

next in thread | previous in thread | raw e-mail | index | archive | help
In message <Pine.BSF.4.10.9908211250310.7595-100000@heidi.plazza.it> Nick Hibma writes:
: Does anyone know an inexpensive algorithm (O(1)) to go from an number to
: the next (lower or higher) power of two.

1 << ffs(x)

Warner


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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199908212138.PAA48856>