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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7e15102eb14c0020 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.87.161 with SMTP id az1mr1474975pab.38.1349339141270; Thu, 04 Oct 2012 01:25:41 -0700 (PDT) Path: t10ni23609894pbh.0!nntp.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: highest bit, statically determined References: <50673111$0$9505$9b4e6d93@newsspool1.arcor-online.net> <38594cbf-b52d-4002-8db9-410f55126a09@googlegroups.com> <50694f43$0$6577$9b4e6d93@newsspool3.arcor-online.net> <036db9eb-36e8-4a2e-8832-cecd9f1f4e2d@googlegroups.com> <506a0b6f$0$9525$9b4e6d93@newsspool1.arcor-online.net> Date: Thu, 04 Oct 2012 04:25:37 -0400 Message-ID: <854nmaskxq.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (windows-nt) Cancel-Lock: sha1:m6KHR6XdRkcKQjtnECOOygfJGE8= MIME-Version: 1.0 X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 1f38b506d4805e029e66120712 X-Received-Bytes: 2059 Content-Type: text/plain Date: 2012-10-04T04:25:37-04:00 List-Id: Brian Drummond writes: > On Mon, 01 Oct 2012 23:30:24 +0200, Georg Bauhaus wrote: > >> On 01.10.12 10:52, Anatoly Chernyshev wrote: >>> (0|1=>0,2|3=>1,4..7=>2, 8..15=>3, 16..31=>4,32..63=>5, 64..127=>6, >>> 128..255=>7); >> >> 68580000 2.653934000 68580000 2.021029000 68580000 27.702262000 >> 68580000 1.173348000 -- first_1_bit_table >> >> I guess the approaches can be used together for larger N-tets. > > Just for completeness, > > function first_bit_case(N:Octet) return natural is > begin > case N is > when 0 => return 0; > when 1 => return 1; > when 2..3 => return 2; > when 4..7 => return 3; > when 8..15 => return 4; > when 16..31 => return 5; > when 32..63 => return 6; > when 64..127 => return 7; > when others => return 8; > end case; > end first_bit_case; Even better; binary search if/then/else instead of a linear case statement; that cuts the number of compares significantly, especially for larger word sizes. -- -- Stephe