From: vincent.diemunsch@gmail.com
Subject: Re: Efficient Bit Vector Manipulation.
Date: Mon, 18 May 2015 04:43:51 -0700 (PDT)
Date: 2015-05-18T04:43:51-07:00 [thread overview]
Message-ID: <110bca30-dd79-4c8d-8a3f-8c39a2e24688@googlegroups.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1505180949370.30700@debian>
> The following should give you the k you ask for:
>
> type Position_Type is range 0 .. 32;
>
> function Significant_Bits(I: Int) return Position_Type is
> Result: Position_Type := 0;
> Value: Int := I;
> begin
> while Value > 1 loop
> Result := Result + 1;
> Value := Value / 2;
> end loop;
> return Result;
> end Significant_Bits;
>
Thank you Stephan. This is indeed the obvious solution.
There are much faster ones on the site given by Niklas.
prev parent reply other threads:[~2015-05-18 11:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-15 12:07 Efficient Bit Vector Manipulation Vincent
2015-05-15 12:48 ` Colin Paul de Gloucester
2015-05-16 17:12 ` Dennis Lee Bieber
2015-05-15 16:26 ` Niklas Holsti
2015-05-16 11:58 ` vincent.diemunsch
2015-05-15 16:58 ` Jeffrey R. Carter
2015-05-16 12:06 ` vincent.diemunsch
2015-05-17 13:55 ` robin.vowels
2015-05-18 7:53 ` Stefan.Lucks
2015-05-18 11:43 ` vincent.diemunsch [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox