From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: highest bit, statically determined
Date: Sat, 29 Sep 2012 20:59:43 +0200
Date: 2012-09-29T20:59:43+02:00 [thread overview]
Message-ID: <5067451f$0$9524$9b4e6d93@newsspool1.arcor-online.net> (raw)
In-Reply-To: <506739BF.20407@obry.net>
On 29.09.12 20:11, Pascal Obry wrote:
>> Highest_Bit_In_Octet : constant :=
>> Natural'Max
>> (8 * Boolean'Pos (N / 2**7 > 0),
...
>> (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))))))));
>
> if N > 128 then
> return 8;
> elsif N > 64
> return 7;
> elsif ...
>
> elsif N > 0 then
> return 1;
> end if;
>
The N > 2**X part is good, thanks for the answer that removed
a fair bit of fog. But the "return X" indicates that the solution
cannot be static, or can it?
There might be an expression in Ada 2012 that does it. Alas,
I cannot use Ada 2012 yet---which I should have mentioned!
Highest_Bit_In_Octet_2012 : constant :=
(if N > 2**7 then 8
elsif N > 2**6 then 7
elsif N > 2**5 then 6
elsif N > 2**4 then 5
elsif N > 2**3 then 4
elsif N > 2**2 then 3
elsif N > 2**1 then 2
elsif N > 2**0 then 1
else 0);
next prev parent reply other threads:[~2012-09-29 18:59 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 [this message]
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
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