From: Georg Bauhaus <rm-host.bauhaus@maps.arcor.de>
Subject: Re: highest bit, statically determined
Date: 03 Oct 2012 18:54:07 GMT
Date: 2012-10-03T20:54:07+02:00 [thread overview]
Message-ID: <441830536370982493.692537rm-host.bauhaus-maps.arcor.de@news.arcor.de> (raw)
In-Reply-To: cd5ac9f5-ebd4-4c1a-8fee-478dd2680a43@googlegroups.com
<kalvink65@gmail.com> wrote:
> How about binary search algorithm with constant execution time:
>
> Binary_Search_Highest_Bit_In_Octet_2012 : constant :=
> (if N > (2**4)-1 then -- determine upper or lower nibble
> -- upper nibble
> if N > (2**6)-1
> -- bits 7 and 6
> if N > (2**7)-1 then
>
Isn't this about the same as the recursive one?
(It uses Boolean'Pos around the third if.)
Also, I don't think its complexity is constant, since the number
of conditionals depends on the position of the first 1 bit.
That dependence is gone with the table.
Relative performance might depend on whether shift
and jump is more expensive than another branch of
conditionals. I'm guessing.
next prev parent reply other threads:[~2012-10-11 7:55 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-29 17:34 highest bit, statically determined Georg Bauhaus
2012-09-29 18:11 ` Pascal Obry
2012-09-29 18:59 ` Georg Bauhaus
2012-09-29 19:18 ` Georg Bauhaus
2012-09-29 18:57 ` Bill Findlay
2012-09-29 19:16 ` Bill Findlay
2012-09-29 21:36 ` Georg Bauhaus
2012-09-29 22:06 ` Georg Bauhaus
2012-09-29 23:38 ` Bill Findlay
2012-09-30 15:01 ` Vadim Godunko
2012-11-04 20:45 ` Yannick Duchêne (Hibou57)
2012-11-04 22:00 ` Bill Findlay
2012-09-30 15:39 ` Anatoly Chernyshev
2012-09-30 18:36 ` Shark8
2012-10-01 8:07 ` Georg Bauhaus
2012-10-01 8:11 ` Georg Bauhaus
2012-10-01 8:52 ` Anatoly Chernyshev
2012-10-01 21:30 ` Georg Bauhaus
2012-10-01 22:55 ` Shark8
2012-10-01 23:25 ` Georg Bauhaus
2012-10-02 11:03 ` Brian Drummond
2012-10-03 9:30 ` kalvink65
2012-10-03 18:54 ` Georg Bauhaus [this message]
2012-10-04 7:46 ` Georg Bauhaus
2012-10-04 8:25 ` Stephen Leake
2012-10-04 10:01 ` kalvin.news
2012-10-05 7:50 ` Anatoly Chernyshev
2012-10-05 8:38 ` Anatoly Chernyshev
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox