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: a07f3367d7,7e15102eb14c0020 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.224.31.20 with SMTP id w20mr12088154qac.2.1349017314327; Sun, 30 Sep 2012 08:01:54 -0700 (PDT) Received: by 10.52.23.145 with SMTP id m17mr2498853vdf.0.1349017314307; Sun, 30 Sep 2012 08:01:54 -0700 (PDT) Path: e10ni135431130qan.0!nntp.google.com!l8no18612483qao.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 30 Sep 2012 08:01:54 -0700 (PDT) In-Reply-To: <506769fb$0$6580$9b4e6d93@newsspool3.arcor-online.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=95.153.251.1; posting-account=niG3UgoAAAD7iQ3takWjEn_gw6D9X3ww NNTP-Posting-Host: 95.153.251.1 References: <50673111$0$9505$9b4e6d93@newsspool1.arcor-online.net> <506769fb$0$6580$9b4e6d93@newsspool3.arcor-online.net> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: highest bit, statically determined From: Vadim Godunko Injection-Date: Sun, 30 Sep 2012 15:01:54 +0000 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-09-30T08:01:54-07:00 List-Id: On Sunday, September 30, 2012 1:37:00 AM UTC+4, Georg Bauhaus wrote: > > Daringly, I have tried to steal the idea and try a comparison (out of > curiosity, not for the static thing). GCC performs simple tail call > elimination (explaining the Shift parameter)! > If you don't need static function, you can use following function (GCC can precompute its result for static value): with Interfaces.C; use Interfaces.C; function Bit (X : Unsigned) return Unsigned; pragma Inline (Bit); function Bit (X : Unsigned) return Unsigned is function CLZ (X : Unsigned) return Unsigned; pragma Import (Intrinsic, CLZ, "__builtin_clz"); begin if X = 0 then -- XXX Return what you want. return 0; else return Unsigned'Size - CLZ (X); end if; end Bit;