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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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.77.39 with SMTP id p7mr398073paw.0.1349256651484; Wed, 03 Oct 2012 02:30:51 -0700 (PDT) Received: by 10.52.72.197 with SMTP id f5mr100023vdv.17.1349256651118; Wed, 03 Oct 2012 02:30:51 -0700 (PDT) Path: t10ni23601286pbh.0!nntp.google.com!kr7no2527607pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 3 Oct 2012 02:30:51 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=83.150.124.2; posting-account=4R-0mAoAAABPtAudIsI9GODoqxaoD_JM NNTP-Posting-Host: 83.150.124.2 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> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: highest bit, statically determined From: kalvink65@gmail.com Injection-Date: Wed, 03 Oct 2012 09:30:51 +0000 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-10-03T02:30:51-07:00 List-Id: 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 7 else 6 else -- bits 5 and 4 if N > (2**5)-1 then 5 else 4 else -- lower nibble if N > (2**2)-1 then -- bits 3 and 2 if N > (2**3)-1 then 3 else 2 else -- bits 1 and 0 if N > (2**1)-1 then 1 else 0); Disclaimer: I am not an Ada programmer, so this might not compile, but describes the idea anyway. - Kalvin