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.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7e15102eb14c0020,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.180.86.97 with SMTP id o1mr521092wiz.2.1348940050543; Sat, 29 Sep 2012 10:34:10 -0700 (PDT) Path: q11ni99025952wiw.1!nntp.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!217.188.199.168.MISMATCH!takemy.news.telefonica.de!telefonica.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Sat, 29 Sep 2012 19:34:09 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: highest bit, statically determined Message-ID: <50673111$0$9505$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 29 Sep 2012 19:34:09 CEST NNTP-Posting-Host: 50c0702c.newsspool1.arcor-online.net X-Trace: DXC=M\I9E32f4FN[kmHKHnaEnMic==]BZ:afN4Fo<]lROoRAnkgeX?EC@@@8WEnDiKGIRBPCY\c7>ejVHNH>negGeW]HIGQbNQYch8I X-Complaints-To: usenet-abuse@arcor.de Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-09-29T19:34:09+02:00 List-Id: Is there a shorter/better way of having the compiler find the highest bit = 1 in a static numeric constant? If N is such a constant, e.g. Some_Type'Last where Some_Type'Size = 8 and its bound are static, then Highest_Bit_In_Octet : constant := Natural'Max (8 * Boolean'Pos (N / 2**7 > 0), Natural'Max (7 * Boolean'Pos (N / 2**6 > 0), Natural'Max (6 * Boolean'Pos (N / 2**5 > 0), Natural'Max (5 * Boolean'Pos (N / 2**4 > 0), Natural'Max (4 * Boolean'Pos (N / 2**3 > 0), Natural'Max (3 * Boolean'Pos (N / 2**2 > 0), Natural'Max (2 * Boolean'Pos (N / 2**1 > 0), Natural'Max (1 * Boolean'Pos (N / 2**0 > 0), 0))))))));