From: Anatoly Chernyshev <achernyshev@gmail.com>
Subject: Re: highest bit, statically determined
Date: Fri, 5 Oct 2012 00:50:15 -0700 (PDT)
Date: 2012-10-05T00:50:15-07:00 [thread overview]
Message-ID: <cdacbebf-e532-485a-acf2-590a94d86660@googlegroups.com> (raw)
In-Reply-To: <fd41da3a-288e-4717-a511-3f6dc44b1ac5@googlegroups.com>
On Thursday, October 4, 2012 2:01:50 PM UTC+4, kalvi...@gmail.com wrote:
> maanantai, 1. lokakuuta 2012 11.52.43 UTC+3 Anatoly Chernyshev kirjoitti:
>
> > >
>
> >
>
> > > 68580000 1.687923000
>
> >
>
> > >
>
> >
>
> > > 68580000 1.447859000
>
> >
>
> > >
>
> >
>
> > > 68580000 24.481472000
>
> >
>
> >
>
> >
>
> > Yes, that could be expected. Here's the draft lightning-fast version:
>
> >
>
> >
>
> >
>
> > procedure xx is
>
> >
>
> > last_bit_a: array(0..255) of natural:=(0|1=>0,2|3=>1,4..7=>2, 8..15=>3, 16..31=>4,32..63=>5, 64..127=>6, 128..255=>7);
>
> >
>
> > N:natural;
>
> >
>
> > begin
>
> >
>
> > ...
>
> >
>
> > Highest_Bit_In_Octet:=last_bit_a(N);
>
> >
>
> > ...
>
> >
>
> > end xx;
>
>
>
> This can be optimised for improved size so that we create a lookup table only for a nibble values (0..15), and divide the handling into two parts according to whether the higher nibble is zero or non-zero. The end result would be a slighter slower execution speed but less code space. And this method can easily be extended to larger data sizes, too.
>
>
>
> - Kalvin
If you play with the memory optimization (I'm not very good at it), the array above will be made of 3 bit integers (0 to 7), which occupy lousy 3*256/8= 96 bytes of memory. Laughable by today's standards. Even if you go for long_long_long..._integers, the table will be quite small.
next prev parent reply other threads:[~2012-10-05 7:50 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
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 [this message]
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