From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Efficient Bit Vector Manipulation. Date: Fri, 15 May 2015 09:58:11 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <62605fe5-6ecf-4750-b13c-24bce65e3439@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Fri, 15 May 2015 16:57:07 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="a3855fbfe1a666be9aefba0563039ed5"; logging-data="15751"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/2Lip9XLZfmIiiAJGQL6hp3mL3XzVXyjU=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: <62605fe5-6ecf-4750-b13c-24bce65e3439@googlegroups.com> Cancel-Lock: sha1:hW/tKw3SiLpWMCfcVfDZmXOBIe0= Xref: news.eternal-september.org comp.lang.ada:25887 Date: 2015-05-15T09:58:11-07:00 List-Id: On 05/15/2015 05:07 AM, Vincent wrote: > > I need to extract in a very efficient way, information from the bit sequence > that represents a 32 bits Positive number, named I > 0. Given your need to extract sequences of bits as integers, I'd say using an Unsigned_* type from Interfaces would probably be best. This also has the advantage of being endian independent. Finding the most-significant 1 bit can be done with a binary search. Shifting and masking out the B and E values is then fairly simple. -- Jeff Carter "C++ is like jamming a helicopter inside a Miata and expecting some sort of improvement." Drew Olbrich 51