Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

All life evolves by the differential survival of replicating entities. -- Dawkins


devel / comp.lang.c / Re: portable way to get highest bit set?

SubjectAuthor
* portable way to get highest bit set?candycanearter07
+* Re: portable way to get highest bit set?Anton Shepelev
|+* Re: portable way to get highest bit set?David Brown
||`* Re: portable way to get highest bit set?Anton Shepelev
|| `* Re: portable way to get highest bit set?David Brown
||  `* Re: portable way to get highest bit set?Anton Shepelev
||   `* Re: portable way to get highest bit set?David Brown
||    +- Re: portable way to get highest bit set?Anton Shepelev
||    `* Re: portable way to get highest bit set?Ben Bacarisse
||     `- Re: portable way to get highest bit set?David Brown
|`* Re: portable way to get highest bit set?candycanearter07
| +- Re: portable way to get highest bit set?David Brown
| +* Re: portable way to get highest bit set?Ian C
| |+- Re: portable way to get highest bit set?Tim Rentsch
| |`- Re: portable way to get highest bit set?candycanearter07
| +* Re: portable way to get highest bit set?Tim Rentsch
| |+* Re: portable way to get highest bit set?David Brown
| ||+* Re: portable way to get highest bit set?Ben Bacarisse
| |||+* Re: portable way to get highest bit set?David Brown
| ||||`* Re: portable way to get highest bit set?Ben Bacarisse
| |||| `- Re: portable way to get highest bit set?David Brown
| |||`- Re: portable way to get highest bit set?Tim Rentsch
| ||+* Re: portable way to get highest bit set?Michael S
| |||`* Re: portable way to get highest bit set?Michael S
| ||| `- Re: portable way to get highest bit set?Anton Shepelev
| ||+- Re: portable way to get highest bit set?Michael S
| ||+- Re: portable way to get highest bit set?Michael S
| ||`- Re: portable way to get highest bit set?Michael S
| |`* Re: portable way to get highest bit set?Anton Shepelev
| | +- Re: portable way to get highest bit set?Michael S
| | `* Re: portable way to get highest bit set?Tim Rentsch
| |  `* Re: portable way to get highest bit set?Anton Shepelev
| |   `* Re: portable way to get highest bit set?Tim Rentsch
| |    +* Re: portable way to get highest bit set?Scott Lurndal
| |    |`- Re: portable way to get highest bit set?Tim Rentsch
| |    +* Re: portable way to get highest bit set?Michael S
| |    |`* Re: portable way to get highest bit set?Tim Rentsch
| |    | +* Re: portable way to get highest bit set?Michael S
| |    | |`* Re: portable way to get highest bit set?Tim Rentsch
| |    | | +* Re: portable way to get highest bit set?Michael S
| |    | | |`* Re: portable way to get highest bit set?Tim Rentsch
| |    | | | +- Re: portable way to get highest bit set?Branimir Maksimovic
| |    | | | `* Re: portable way to get highest bit set?Michael S
| |    | | |  `* Re: portable way to get highest bit set?Michael S
| |    | | |   `* Re: portable way to get highest bit set?Tim Rentsch
| |    | | |    `* Re: portable way to get highest bit set?Michael S
| |    | | |     +- Re: portable way to get highest bit set?Chris M. Thomasson
| |    | | |     `* Re: portable way to get highest bit set?Tim Rentsch
| |    | | |      `* Re: portable way to get highest bit set?Keith Thompson
| |    | | |       `- Re: portable way to get highest bit set?Tim Rentsch
| |    | | `* Re: portable way to get highest bit set?jak
| |    | |  `* Re: portable way to get highest bit set?Tim Rentsch
| |    | |   `* Re: portable way to get highest bit set?jak
| |    | |    `* Re: portable way to get highest bit set?Tim Rentsch
| |    | |     `* Re: portable way to get highest bit set?jak
| |    | |      +* Re: portable way to get highest bit set?Tim Rentsch
| |    | |      |`* Re: portable way to get highest bit set?jak
| |    | |      | `- Re: portable way to get highest bit set?Tim Rentsch
| |    | |      `* Re: portable way to get highest bit set?Kaz Kylheku
| |    | |       `* Re: portable way to get highest bit set?Bart
| |    | |        `* Re: portable way to get highest bit set?Michael S
| |    | |         `* Re: portable way to get highest bit set?Ben Bacarisse
| |    | |          `- Re: portable way to get highest bit set?Michael S
| |    | +* Re: portable way to get highest bit set?Anton Shepelev
| |    | |+* Re: portable way to get highest bit set?Tim Rentsch
| |    | ||`* Re: portable way to get highest bit set?Anton Shepelev
| |    | || +- Re: portable way to get highest bit set?Tim Rentsch
| |    | || `* Re: portable way to get highest bit set?Anton Shepelev
| |    | ||  +- Re: portable way to get highest bit set?Bart
| |    | ||  `* Re: portable way to get highest bit set?Tim Rentsch
| |    | ||   `* Re: portable way to get highest bit set?Anton Shepelev
| |    | ||    `- Re: portable way to get highest bit set?Tim Rentsch
| |    | |`* Re: portable way to get highest bit set?Tim Rentsch
| |    | | +* Re: portable way to get highest bit set?Michael S
| |    | | |+* Re: portable way to get highest bit set?Tim Rentsch
| |    | | ||`- Re: portable way to get highest bit set?Michael S
| |    | | |`* Re: portable way to get highest bit set?Anton Shepelev
| |    | | | `- Re: portable way to get highest bit set?Tim Rentsch
| |    | | `- Re: portable way to get highest bit set?David Brown
| |    | `* Re: portable way to get highest bit set?Michael S
| |    |  +- Re: portable way to get highest bit set?Michael S
| |    |  +- False positives in spam filter? (was: Re: portable way to getRay Banana
| |    |  +- Re: portable way to get highest bit set?Anton Shepelev
| |    |  `- Re: portable way to get highest bit set?Ben Bacarisse
| |    `* Re: portable way to get highest bit set?Anton Shepelev
| |     `* Re: portable way to get highest bit set?Tim Rentsch
| |      `* Re: portable way to get highest bit set?Anton Shepelev
| |       `- Re: portable way to get highest bit set?Tim Rentsch
| +* Re: portable way to get highest bit set?Richard Harnden
| |`* Re: portable way to get highest bit set?candycanearter07
| | `* Re: portable way to get highest bit set?Bart
| |  +- Re: portable way to get highest bit set?Keith Thompson
| |  `- Re: portable way to get highest bit set?candycanearter07
| `- Re: portable way to get highest bit set?Tim Rentsch
+- Re: portable way to get highest bit set?Ben Bacarisse
+* Re: portable way to get highest bit set?Lew Pitcher
|`* Re: portable way to get highest bit set?Lew Pitcher
| `* Re: portable way to get highest bit set?Lew Pitcher
|  `* Re: portable way to get highest bit set?Tim Rentsch
|   `* Re: portable way to get highest bit set?Bart
|    `* Re: portable way to get highest bit set?Tim Rentsch
+- Re: portable way to get highest bit set?Kaz Kylheku
+* Re: portable way to get highest bit set?jak
+* Re: portable way to get highest bit set?Blue-Maned_Hawk
`* Re: portable way to get highest bit set?Kaz Kylheku

Pages:12345678
Re: portable way to get highest bit set?

<ugfrqs$ba5k$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29894&group=comp.lang.c#29894

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 07:03:23 +0200
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <ugfrqs$ba5k$1@dont-email.me>
References: <ug5gvh$1jkar$3@dont-email.me> <ug70cu$219ov$1@dont-email.me>
<878r884vi5.fsf@bsb.me.uk> <ug86d3$2c9mp$1@dont-email.me>
<87edi0qide.fsf@bsb.me.uk> <ug8r5q$2gqj4$1@dont-email.me>
<ug9p1o$2nihu$1@dont-email.me> <86cyxgabe6.fsf@linuxsc.com>
<ugfo4p$ameh$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 15 Oct 2023 05:03:24 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e564dff263fcef672c2d3b215519151a";
logging-data="370868"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19w6FNTe7cFPGAPack6cbNk"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
Cancel-Lock: sha1:u89731Q1bjyyPKrlnrKLk1L6McU=
In-Reply-To: <ugfo4p$ameh$1@dont-email.me>
 by: jak - Sun, 15 Oct 2023 05:03 UTC

jak ha scritto:
> Tim Rentsch ha scritto:
>> jak <nospam@please.ty> writes:
>>
>>> unsigned long h_bit(unsigned long val)
>>> {
>>>      int i;
>>>      for(i = 0; val > 1; val /= 2, i++);
>>>      return val << i;
>>> }
>>
>> A nice compact solution.  I like the way it
>> naturally deals with the case when val is zero.
>>
>
> This is not true because if Val is 0 also the bit shifted to left is,
> so also its result is 0. This one of the reason why the exit from the
> loop is greater than 1.
>

Sorry about the answer. I have translated your comment badly.

Re: portable way to get highest bit set?

<20231014222046.551@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29895&group=comp.lang.c#29895

  copy link   Newsgroups: comp.lang.c alt.comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c,alt.comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 05:26:44 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <20231014222046.551@kylheku.com>
References: <ug5gvh$1jkar$3@dont-email.me> <20231011143809.748@kylheku.com>
Injection-Date: Sun, 15 Oct 2023 05:26:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fec3c87fe0900e48c164f5162d075625";
logging-data="375351"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18YxmStwTuxRL65rT/AQycYsy0kkK6+Vrs="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:CVPpvoCxkpSTmL/72z6+Vj788gw=
 by: Kaz Kylheku - Sun, 15 Oct 2023 05:26 UTC

On 2023-10-11, Kaz Kylheku <864-117-4973@kylheku.com> wrote:
> E.g. 32 bit code:
>
> uint32_t fill_mask_down(uint32_t x)
> {
> x |= x >> 1; // e.g. 1000...0000 -> 1100...0000
> x |= x >> 2; // e.g. 1100...0000 -> 1111...0000
> x |= x >> 4; // e.g. 11110000... -> 11111111...
> x |= x >> 8;
> x |= x >> 16;
>
> return x;
> }
>
> Thus:
>
> uint32_t isolate_highest_bit(uint32_t x)
> {
> uint32_t m = fill_mask_down(x);
> return m ^ (m >> 1);
> }
>

I guess this went over people's heads?

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: portable way to get highest bit set?

<22f5deb6-1cfe-4a7e-81d9-f4da4da3ce32n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29896&group=comp.lang.c#29896

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a0c:fa82:0:b0:66d:13ac:275e with SMTP id o2-20020a0cfa82000000b0066d13ac275emr205730qvn.13.1697354918632; Sun, 15 Oct 2023 00:28:38 -0700 (PDT)
X-Received: by 2002:a05:6808:2382:b0:3a7:2434:615a with SMTP id bp2-20020a056808238200b003a72434615amr15350274oib.4.1697354918357; Sun, 15 Oct 2023 00:28:38 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!69.80.99.14.MISMATCH!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 15 Oct 2023 00:28:37 -0700 (PDT)
In-Reply-To: <20231014222046.551@kylheku.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <ug5gvh$1jkar$3@dont-email.me> <20231011143809.748@kylheku.com> <20231014222046.551@kylheku.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <22f5deb6-1cfe-4a7e-81d9-f4da4da3ce32n@googlegroups.com>
Subject: Re: portable way to get highest bit set?
From: already5...@yahoo.com (Michael S)
Injection-Date: Sun, 15 Oct 2023 07:28:38 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 39
 by: Michael S - Sun, 15 Oct 2023 07:28 UTC

On Sunday, October 15, 2023 at 8:27:00 AM UTC+3, Kaz Kylheku wrote:
> On 2023-10-11, Kaz Kylheku <864-11...@kylheku.com> wrote:
> > E.g. 32 bit code:
> >
> > uint32_t fill_mask_down(uint32_t x)
> > {
> > x |= x >> 1; // e.g. 1000...0000 -> 1100...0000
> > x |= x >> 2; // e.g. 1100...0000 -> 1111...0000
> > x |= x >> 4; // e.g. 11110000... -> 11111111...
> > x |= x >> 8;
> > x |= x >> 16;
> >
> > return x;
> > }
> >
> > Thus:
> >
> > uint32_t isolate_highest_bit(uint32_t x)
> > {
> > uint32_t m = fill_mask_down(x);
> > return m ^ (m >> 1);
> > }
> >
>
> I guess this went over people's heads?
>
> --
> TXR Programming Language: http://nongnu.org/txr
> Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
> Mastodon: @Kazi...@mstdn.ca
> NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Not over my head.
My O(log(N)) variant is inspired by your solution.
It is essentially the same like yours, with only difference that I tried to meet
requirement of Tim Rentsch to code it in a manner independent of number
of bits in x.
Sorry for not giving you the credit.

Re: portable way to get highest bit set?

<86r0lw8erq.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29898&group=comp.lang.c#29898

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 01:35:05 -0700
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <86r0lw8erq.fsf@linuxsc.com>
References: <ug5gvh$1jkar$3@dont-email.me> <ug70cu$219ov$1@dont-email.me> <878r884vi5.fsf@bsb.me.uk> <ug86d3$2c9mp$1@dont-email.me> <87edi0qide.fsf@bsb.me.uk> <ug8r5q$2gqj4$1@dont-email.me> <ug9p1o$2nihu$1@dont-email.me> <86cyxgabe6.fsf@linuxsc.com> <ugfo4p$ameh$1@dont-email.me> <ugfrqs$ba5k$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="eb478ed0db5b06d993c3ccd040701c7e";
logging-data="440333"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/g68YYkaXNxaesu6XetLGwXcvL+XkD3IQ="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:NLiGcTO8TnlQNcyHwpzPnh70TRw=
sha1:dySae5+7kunKga4lcIgtljZZpNo=
 by: Tim Rentsch - Sun, 15 Oct 2023 08:35 UTC

jak <nospam@please.ty> writes:

> jak ha scritto:
>
>> Tim Rentsch ha scritto:
>>
>>> jak <nospam@please.ty> writes:
>>>
>>>> unsigned long h_bit(unsigned long val)
>>>> {
>>>> int i;
>>>> for(i = 0; val > 1; val /= 2, i++);
>>>> return val << i;
>>>> }
>>>
>>> A nice compact solution. I like the way it
>>> naturally deals with the case when val is zero.
>>
>> This is not true because if Val is 0 also the bit shifted to left
>> is, so also its result is 0. This one of the reason why the exit
>> from the loop is greater than 1.
>
> Sorry about the answer. I have translated your comment badly.

No worries. I see how it works, and it's cool.

Re: portable way to get highest bit set?

<20231015113545.0000150f@yahoo.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29899&group=comp.lang.c#29899

  copy link   Newsgroups: comp.lang.c alt.comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: already5...@yahoo.com (Michael S)
Newsgroups: comp.lang.c,alt.comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 11:35:45 +0300
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <20231015113545.0000150f@yahoo.com>
References: <ug5gvh$1jkar$3@dont-email.me>
<20231011143809.748@kylheku.com>
<20231014222046.551@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="2bb02aa0fcb965889eeb4a17a6ee651c";
logging-data="2631684"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+syZyVTwCUYLfi171AgaD7hLCF34HLiuY="
Cancel-Lock: sha1:uvYFttHYw7TrZ3HYn/kN2M07/x8=
X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
 by: Michael S - Sun, 15 Oct 2023 08:35 UTC

On Sun, 15 Oct 2023 05:26:44 -0000 (UTC)
Kaz Kylheku <864-117-4973@kylheku.com> wrote:

> On 2023-10-11, Kaz Kylheku <864-117-4973@kylheku.com> wrote:
> > E.g. 32 bit code:
> >
> > uint32_t fill_mask_down(uint32_t x)
> > {
> > x |= x >> 1; // e.g. 1000...0000 -> 1100...0000
> > x |= x >> 2; // e.g. 1100...0000 -> 1111...0000
> > x |= x >> 4; // e.g. 11110000... -> 11111111...
> > x |= x >> 8;
> > x |= x >> 16;
> >
> > return x;
> > }
> >
> > Thus:
> >
> > uint32_t isolate_highest_bit(uint32_t x)
> > {
> > uint32_t m = fill_mask_down(x);
> > return m ^ (m >> 1);
> > }
> >
>
> I guess this went over people's heads?
>

Not over my head.
My O(log(N)) variant is inspired by your solution.
It is essentially the same like yours, with only difference that I
tried to meet requirement of Tim Rentsch to code it in a manner
independent of number of bits in x.
Sorry for not giving you the credit.

When coded as below, it become more clear that idea is the same like
yours:

T
highest_bit_set( T u ){
for (int rshift = 1; ((u+1) & u) != 0; rshift += rshift)
u |= (u >> rshift);
return u ^ (u>>1);
}

Re: portable way to get highest bit set?

<86lec48ebs.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29900&group=comp.lang.c#29900

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 01:44:39 -0700
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <86lec48ebs.fsf@linuxsc.com>
References: <ug5gvh$1jkar$3@dont-email.me> <20231011143809.748@kylheku.com> <20231014222046.551@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="eb478ed0db5b06d993c3ccd040701c7e";
logging-data="440333"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19cqKIvvx+TZH5n7ByM8q38613ogxEBEng="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:9CL6hokuQPSaJOrA9D5fZ7FgA0w=
sha1:TWM5SJpZUMquuT/D5Lfs9fWX1kU=
 by: Tim Rentsch - Sun, 15 Oct 2023 08:44 UTC

Kaz Kylheku <864-117-4973@kylheku.com> writes:

> On 2023-10-11, Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>
>> E.g. 32 bit code:
>>
>> uint32_t fill_mask_down(uint32_t x)
>> {
>> x |= x >> 1; // e.g. 1000...0000 -> 1100...0000
>> x |= x >> 2; // e.g. 1100...0000 -> 1111...0000
>> x |= x >> 4; // e.g. 11110000... -> 11111111...
>> x |= x >> 8;
>> x |= x >> 16;
>>
>> return x;
>> }
>>
>> Thus:
>>
>> uint32_t isolate_highest_bit(uint32_t x)
>> {
>> uint32_t m = fill_mask_down(x);
>> return m ^ (m >> 1);
>> }
>
> I guess this went over people's heads?

Not at all. It's a well-known technique. But it doesn't
address the central ask for an approach that works no
matter how wide the value type is.

Re: portable way to get highest bit set?

<20231015124603.00004072@yahoo.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29902&group=comp.lang.c#29902

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: already5...@yahoo.com (Michael S)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 12:46:03 +0300
Organization: A noiseless patient Spider
Lines: 91
Message-ID: <20231015124603.00004072@yahoo.com>
References: <ug5gvh$1jkar$3@dont-email.me>
<20231011102714.44a870af4dfe68f756974953@g{oogle}mail.com>
<ug6huc$1rvp1$1@dont-email.me>
<86h6mxawqq.fsf@linuxsc.com>
<20231012111100.272c96b3209baad26a150e55@g{oogle}mail.com>
<86cyxkb2ka.fsf@linuxsc.com>
<20231012141719.99f5a10ec921db3ee6f7d948@g{oogle}mail.com>
<864jiwaqic.fsf@linuxsc.com>
<20231012173021.0000149c@yahoo.com>
<86v8bbanjv.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="2bb02aa0fcb965889eeb4a17a6ee651c";
logging-data="467555"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18JCBaKWCnOLxCvaJSGw7Zh9YU2PXp98wc="
Cancel-Lock: sha1:aXFCs5BPavYVzt2xzqY9ODfyh+o=
X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
 by: Michael S - Sun, 15 Oct 2023 09:46 UTC

Turned out that people that read this group through Eternal September
had never seen my answer from ~3 days ago. Right now ES spam filter is
rather unpredictable and appear to suffer both from insufficient
strictness and from false positives. i2pm2 spam filter is considerably
better
Anyway, I'd post my reply again below.

On Thu, 12 Oct 2023 08:05:40 -0700
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

> Michael S <already5chosen@yahoo.com> writes:
>
> > On Thu, 12 Oct 2023 07:01:47 -0700
> > Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
> >
> >> Anton Shepelev <anton.txt@g{oogle}mail.com> writes:
> >>
> >>> Tim Rentsch:
> >>>
> >>>> But the approach you are using requires knowing the size
> >>>> of the type involved. The challenge is to write code that
> >>>> works without having to know the size in advance.
> >>>
> >>> Well, I could use macros, or the largest integer type, or:
> >>
> >> Neither necessary nor sufficient. The code should work for
> >> the type T being __uint128_t, which is larger than uintmax_t.
> >>
> >>> #include <stddef.h>
> >>> #include <limits.h>
> >>>
> >>> [..examine value character-by-character, including
> >>> determining if little-endian encoding is used..]
> >>
> >> You're making things more complicated than they need to be.
> >> Looking at character values rather than just values of the type
> >> involved is almost guaranteed to have potential representation
> >> issues. For example, little endian and big endian are not the
> >> only choices possible for endianness.
> >>
> >> Below is a proposed solution that mostly works. What problems
> >> does it have, and how can they be fixed? And can we find
> >> something better?
> >>
> >> /* The type T has been supplied somewhere upstream. It */
> >> /* is an unsigned type, and possibly outside the realm */
> >> /* of 'integer types' as defined by the C standard, as */
> >> /* for example __uint128_t. */
> >>
> >> T
> >> highest_bit_set( T u ){
> >> T r = 1;
> >> while( u>>1 > r ) r <<= 1;
> >> return r;
> >> }
> >
> > That code does not look like working.
>
> Yes, deliberately so. I didn't want to give working
> code yet, so other people could work on the problem.
>
> > That is:
> >
> > T
> > highest_bit_set1( T u ){
> > T r = 0;
> > while (u > r) r = r*2+1;
> > return r ^ (r>>1);
> > }
>
> As expected, this works. I like the way it naturally
> accommodates a zero input.
>
> Can you find a different solution that works in
> logarithmic time rather than linear time?

Naturally, I can. But the code is not as easy to comprehend as I would
like. And I am not sure that for typical distributions with prevalence
of small numbers it is faster than above variant.

T
highest_bit_set2( T u ){
T v;
for (int rshift = 0; (v = (u >> rshift) >> 1) != 0;
rshift = rshift*2+1)
u |= v;
return u ^ (u>>1);
}

Re: portable way to get highest bit set?

<86h6ms8b6i.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29903&group=comp.lang.c#29903

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 02:52:37 -0700
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <86h6ms8b6i.fsf@linuxsc.com>
References: <ug5gvh$1jkar$3@dont-email.me> <20231011143809.748@kylheku.com> <20231014222046.551@kylheku.com> <20231015113545.0000150f@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="eb478ed0db5b06d993c3ccd040701c7e";
logging-data="475715"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187y2Zh55kHb5paj3ABF9Ybkz7s9x3XdzI="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:fNKyUkP/Ll3CQycJp//foFPffB0=
sha1:FhSoMpcMsgddYFC3tI76lFsOY54=
 by: Tim Rentsch - Sun, 15 Oct 2023 09:52 UTC

Michael S <already5chosen@yahoo.com> writes:

> On Sun, 15 Oct 2023 05:26:44 -0000 (UTC)
> Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>
>> On 2023-10-11, Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>>
>>> E.g. 32 bit code:
>>>
>>> uint32_t fill_mask_down(uint32_t x)
>>> {
>>> x |= x >> 1; // e.g. 1000...0000 -> 1100...0000
>>> x |= x >> 2; // e.g. 1100...0000 -> 1111...0000
>>> x |= x >> 4; // e.g. 11110000... -> 11111111...
>>> x |= x >> 8;
>>> x |= x >> 16;
>>>
>>> return x;
>>> }
>>>
>>> Thus:
>>>
>>> uint32_t isolate_highest_bit(uint32_t x)
>>> {
>>> uint32_t m = fill_mask_down(x);
>>> return m ^ (m >> 1);
>>> }
>>
>> I guess this went over people's heads?
>
> Not over my head.
> My O(log(N)) variant is inspired by your solution.
> It is essentially the same like yours, with only difference that I
> tried to meet requirement of Tim Rentsch to code it in a manner
> independent of number of bits in x.
> Sorry for not giving you the credit.

Two short comments on the above. One, the requirement to make
the algorithm size independent came from the OP, not me; I just
expressed that in a way that is apparent in the C code. Two, I
had assumed that most people would already be familiar with the
expanding-shift-and-oring technique; it was one of several I
had already coded before the humorous post with my "favorite"
version.

> When coded as below, it become more clear that idea is the same
> like yours:
>
> T
> highest_bit_set( T u ){
> for (int rshift = 1; ((u+1) & u) != 0; rshift += rshift)
> u |= (u >> rshift);
> return u ^ (u>>1);
> }

I expect to have comments on this and your earlier posted
version soon.

Re: portable way to get highest bit set?

<20231015125912.0000303f@yahoo.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29904&group=comp.lang.c#29904

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: already5...@yahoo.com (Michael S)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 12:59:12 +0300
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <20231015125912.0000303f@yahoo.com>
References: <ug5gvh$1jkar$3@dont-email.me>
<20231011102714.44a870af4dfe68f756974953@g{oogle}mail.com>
<ug6huc$1rvp1$1@dont-email.me>
<86h6mxawqq.fsf@linuxsc.com>
<20231012111100.272c96b3209baad26a150e55@g{oogle}mail.com>
<86cyxkb2ka.fsf@linuxsc.com>
<20231012141719.99f5a10ec921db3ee6f7d948@g{oogle}mail.com>
<864jiwaqic.fsf@linuxsc.com>
<20231012173021.0000149c@yahoo.com>
<86v8bbanjv.fsf@linuxsc.com>
<20231015124603.00004072@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="2bb02aa0fcb965889eeb4a17a6ee651c";
logging-data="467555"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19l6Ft1lrFrApmR4g9BQMb3FIqez8/dL9U="
Cancel-Lock: sha1:0i9GRvcQsCakdvaDWbAa5skDSik=
X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
 by: Michael S - Sun, 15 Oct 2023 09:59 UTC

On Sun, 15 Oct 2023 12:46:03 +0300
Michael S <already5chosen@yahoo.com> wrote:

> Turned out that people that read this group through Eternal September
> had never seen my answer from ~3 days ago. Right now ES spam filter is
> rather unpredictable and appear to suffer both from insufficient
> strictness and from false positives. i2pm2 spam filter is considerably
> better

[O.T.]
As suggested in other thread here, ES users that either can not or do
not want to access comp.lang.c via news.i2pn2.org have an option to see
read-only variant of i2pn2-filtered group at
https://www.novabbs.com/devel/thread.php?group=comp.lang.c

False positives in spam filter? (was: Re: portable way to get highest bit set?)

<slrnuinihr.fbdi.rayban@raybanana.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29905&group=comp.lang.c#29905

  copy link   Newsgroups: comp.lang.c
Followup: eternal-september.support
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!raybanana.eternal-september.org!.POSTED!not-for-mail
From: ray...@raybanana.net (Ray Banana)
Newsgroups: comp.lang.c
Subject: False positives in spam filter? (was: Re: portable way to get
highest bit set?)
Followup-To: eternal-september.support
Date: Sun, 15 Oct 2023 11:17:15 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <slrnuinihr.fbdi.rayban@raybanana.net>
References: <ug5gvh$1jkar$3@dont-email.me>
<20231011102714.44a870af4dfe68f756974953@g{oogle}mail.com>
<ug6huc$1rvp1$1@dont-email.me> <86h6mxawqq.fsf@linuxsc.com>
<20231012111100.272c96b3209baad26a150e55@g{oogle}mail.com>
<86cyxkb2ka.fsf@linuxsc.com>
<20231012141719.99f5a10ec921db3ee6f7d948@g{oogle}mail.com>
<864jiwaqic.fsf@linuxsc.com> <20231012173021.0000149c@yahoo.com>
<86v8bbanjv.fsf@linuxsc.com> <20231015124603.00004072@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 15 Oct 2023 11:17:15 -0000 (UTC)
Injection-Info: raybanana.eternal-september.org; posting-host="dbb9eba6713d843a9b5b61f127a5b1b3";
logging-data="510473"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ZnAIhUUz64B+l1vAEVrbrLbnYUdIVXCI="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:4w5aRfOs95r+sRYQWOOX+Q0q/v4=
 by: Ray Banana - Sun, 15 Oct 2023 11:17 UTC

* Michael S wrote:
> Turned out that people that read this group through Eternal September
> had never seen my answer from ~3 days ago. Right now ES spam filter is
> rather unpredictable and appear to suffer both from insufficient
> strictness and from false positives. i2pm2 spam filter is considerably
> better
> Anyway, I'd post my reply again below.

PMFJI, just a remark regarding the above comment:

I assume you are referring to the article with Message ID

<20231012191641.00007493@yahoo.com>

This article is actually available on E-S. Since you
posted it via E-S, it wouldn't have been scanned by
the spam filter, anyway, as this filter only scans
articles originating from GG and some Highwinds Media
resellers based on the Injection-Info: header.

If you would like to follow up on this issue,
please reply either on eternal-september.support or
to my email address.

--
Пу́тін — хуйло́
http://www.eternal-september.org

Re: portable way to get highest bit set?

<87v8b8otap.fsf@tilde.institute>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29908&group=comp.lang.c#29908

  copy link   Newsgroups: comp.lang.c alt.comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: yet...@tilde.institute (yeti)
Newsgroups: comp.lang.c,alt.comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 14:26:54 +0000
Organization: Democratic Order of Pirates International (DOPI)
Lines: 9
Message-ID: <87v8b8otap.fsf@tilde.institute>
References: <ug5gvh$1jkar$3@dont-email.me> <20231011143809.748@kylheku.com>
<20231014222046.551@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="644206b049adddaa1cc78de1723827c4";
logging-data="591919"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LlLRwIv1dzU4wUG/SfdpB"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:EgRIfo+rfVCvV4zaTtuimlbNZew=
sha1:3lBtE0Imhc5Tijl8mBlXkTkTSA4=
X-Face: ]_G&_b@O$RF(L7zT;DQ3-VU}c"F/_Mgy(4^P1,Tt^#0Cq+\qM&-h\&Z.3UuiwV")n~b;26e
5-s.cF/5tMdha-:]4eBHC9vBXnz4_aNe@d4oijVyix?>pC=tzuQhoD2A8P02+\xO4gNfRBE
`B<kE3T-Gps_d0_6`+0W3E9{D
 by: yeti - Sun, 15 Oct 2023 14:26 UTC

Kaz Kylheku <864-117-4973@kylheku.com> writes:

> I guess this went over people's heads?

Nope.
I've used that before, just not in C yet.

--
Fake signature.

Re: portable way to get highest bit set?

<ugh2jp$jant$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29909&group=comp.lang.c#29909

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 18:05:13 +0200
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <ugh2jp$jant$1@dont-email.me>
References: <ug5gvh$1jkar$3@dont-email.me> <ug70cu$219ov$1@dont-email.me>
<878r884vi5.fsf@bsb.me.uk> <ug86d3$2c9mp$1@dont-email.me>
<87edi0qide.fsf@bsb.me.uk> <ug8r5q$2gqj4$1@dont-email.me>
<ug9p1o$2nihu$1@dont-email.me> <86cyxgabe6.fsf@linuxsc.com>
<ugfo4p$ameh$1@dont-email.me> <ugfrqs$ba5k$1@dont-email.me>
<86r0lw8erq.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 15 Oct 2023 16:05:13 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7a9ff1a5e32faa8e8eb7e27c888078b3";
logging-data="633597"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181Ml8Al8QxbRMizlSxvfpo"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
Cancel-Lock: sha1:979nZoIU4xfCeADasjUqpmXoNos=
In-Reply-To: <86r0lw8erq.fsf@linuxsc.com>
 by: jak - Sun, 15 Oct 2023 16:05 UTC

Tim Rentsch ha scritto:
> jak <nospam@please.ty> writes:
>
>> jak ha scritto:
>>
>>> Tim Rentsch ha scritto:
>>>
>>>> jak <nospam@please.ty> writes:
>>>>
>>>>> unsigned long h_bit(unsigned long val)
>>>>> {
>>>>> int i;
>>>>> for(i = 0; val > 1; val /= 2, i++);
>>>>> return val << i;
>>>>> }
>>>>
>>>> A nice compact solution. I like the way it
>>>> naturally deals with the case when val is zero.
>>>
>>> This is not true because if Val is 0 also the bit shifted to left
>>> is, so also its result is 0. This one of the reason why the exit
>>> from the loop is greater than 1.
>>
>> Sorry about the answer. I have translated your comment badly.
>
> No worries. I see how it works, and it's cool.
>

In addition, GCC translates this code into a really simple way:

h_bit:
mov rax, rcx
cmp rcx, 1
jbe .L1
xor ecx, ecx
..L3:
shr rax
add ecx, 1
cmp rax, 1
jne .L3
sal rax, cl
..L1:
ret

Re: portable way to get highest bit set?

<pan$93111$74afa426$cc67762$31ab3c2b@invalid.invalid>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29910&group=comp.lang.c#29910

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: bluemane...@invalid.invalid (Blue-Maned_Hawk)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 16:57:27 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <pan$93111$74afa426$cc67762$31ab3c2b@invalid.invalid>
References: <ug5gvh$1jkar$3@dont-email.me>
<pan$e0805$faa9a91a$a60476dc$4a90cfa8@invalid.invalid>
<87h6mwu9rk.fsf@nosuchdomain.example.com>
<pan$325f3$70a576a8$3150c04a$26db7b31@invalid.invalid>
<ugagv6$2vs64$1@dont-email.me>
<pan$21acb$49c8a2a6$a1bbf038$1e40c8f0@invalid.invalid>
<878r86rw6y.fsf@nosuchdomain.example.com>
<pan$ccd5a$be70d7a6$e3ed688b$9880acc4@invalid.invalid>
<ugecsv$3u3so$1@dont-email.me>
<pan$b036e$461431b2$2bf7b043$d730da9d@invalid.invalid>
<ugf7og$3ruq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 15 Oct 2023 16:57:27 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="87152a8035316740d6ac7a66237ccfef";
logging-data="630393"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/YzRp/ZrN9eY41Tkuf3pXuyESTnq0AZss="
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:Pj1vSoY/jD6jmQCEfxq09x+xIU4=
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACh0lEQVRYw71Z21bD
MAzzevbfkr4cHjrSXJyL044+MDa6WLEl2SkvkrZ1AbAvXO+bUGSCPYnsuIVGMpm
ZLnjX718GhAKNsp8lON2F9VrhELwIgJlBepkZjA78rVK+FkmNhEJK76UsJlz8+E
rJsjrpYouhLo/SC6qPHgakFOR8wV9+8rCfO/I/oVnmUZUp42/LW2XkLj9TCFNM9
jp5g2EmHZgpYZjCOkYU7sXVogRylJqpdggoFLG1g09Flah/7kErCxzR9HgXPYsq
0glb9cxjIz2Vsk9AmAoCSxECpD713joMKjQqLAtmMqJmXjdVvlMnMQCVITotJd1
z+fh1f1NNo+vuc1KnhWUmY7t03vydTud9BbXCtN3L2PL3bK7JCNG0GHzuZxafyB
fxevCxpm1vrwZltqw6SILCcdoCE6PGQC8wZWDA9Or7Qp5s3lAZezys0nDazs9S9
R0TjwEiksRxLkNPC1NMMWPs1bj0Ei0Yuo+JVtFLuzP1NRJ16qXWN8DhhtmS4PDg
O6mqRxs4bEJrYt087mSIow/1VzW2oFlMQuiuIy/KsUagvhdw6hSjJGlIavbLF8x
j3X47bccLcUSi0dkWh1nUZNhANT1tHKUXrNxNLbd9KPb9wDDVrKwmPQMOPQ1oy6
k5I1DwzDeRJd3jVIhDAUxq3ngzJG4CCkNXZxZVMcjefoK2J0gUY2S3rxz/RuTFx
2zHd9U+obimJXMG4edsk/2j5pTU5G1MmzbRLxkfq5EiT1GGsidvMGzi+1goGb2l
GCrN+nGnV8xj3q3JLRDVPL96vUc7Z4aJ3TN1mVqWAMJMfG+Jxh6TQqP+92iZkCU
xtglds1AB6r0aiSHKcnFck+p/c/0CbacFLQcajGcAAAAASUVORK5CYII=
X-Face: Llanfair­pwllgwyngyll­gogery­chwyrnÂ
­drobwll­llan
? ?­tysilio­gogo­goch
 by: Blue-Maned_Hawk - Sun, 15 Oct 2023 16:57 UTC

James Kuyper wrote:

> If the users of those toolchains aren't interested in using newer
> versions, how is that a problem?

They are intentionally choosing to use obsolete versions.

--

Re: portable way to get highest bit set?

<20231015084712.400@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29911&group=comp.lang.c#29911

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 16:59:02 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <20231015084712.400@kylheku.com>
References: <ug5gvh$1jkar$3@dont-email.me> <20231011143809.748@kylheku.com>
<20231014222046.551@kylheku.com> <86lec48ebs.fsf@linuxsc.com>
Injection-Date: Sun, 15 Oct 2023 16:59:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fec3c87fe0900e48c164f5162d075625";
logging-data="654076"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Xfequvkva4YQDWYblsZQ+0D3DF8U1FEw="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:S98brKiq0eWRNGXg5HfmENYwYXk=
 by: Kaz Kylheku - Sun, 15 Oct 2023 16:59 UTC

On 2023-10-15, Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
> Kaz Kylheku <864-117-4973@kylheku.com> writes:
>
>> On 2023-10-11, Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>>
>>> E.g. 32 bit code:
>>>
>>> uint32_t fill_mask_down(uint32_t x)
>>> {
>>> x |= x >> 1; // e.g. 1000...0000 -> 1100...0000
>>> x |= x >> 2; // e.g. 1100...0000 -> 1111...0000
>>> x |= x >> 4; // e.g. 11110000... -> 11111111...
>>> x |= x >> 8;
>>> x |= x >> 16;
>>>
>>> return x;
>>> }
>>>
>>> Thus:
>>>
>>> uint32_t isolate_highest_bit(uint32_t x)
>>> {
>>> uint32_t m = fill_mask_down(x);
>>> return m ^ (m >> 1);
>>> }
>>
>> I guess this went over people's heads?
>
> Not at all. It's a well-known technique. But it doesn't
> address the central ask for an approach that works no
> matter how wide the value type is.

Oh, if I had to make it work with the unsigned long type, like the other
solutions, I'd probably just do this:

unsigned long fill_mask_down(unsigned long x)
{
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x |= x >> 8;

#if UINT_MAX == UINT32_MAX
x |= x >> 16;
#elif UINT_MAX == UINT64_MAX
x |= x >> 16;
x |= x >> 32;
#elif UINT_MAX != UINT16_MAX
#error port me!
#endif

return x;
}

unsigned long isolate_highest_bit(unsigned long x)
{
unsigned long m = fill_mask_down(x);
return m ^ (m >> 1);
}

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: portable way to get highest bit set?

<pan$b29a$e4923427$117477d2$1f9519d0@invalid.invalid>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29912&group=comp.lang.c#29912

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: bluemane...@invalid.invalid (Blue-Maned_Hawk)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 17:18:29 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <pan$b29a$e4923427$117477d2$1f9519d0@invalid.invalid>
References: <ug5gvh$1jkar$3@dont-email.me>
<pan$e0805$faa9a91a$a60476dc$4a90cfa8@invalid.invalid>
<87h6mwu9rk.fsf@nosuchdomain.example.com>
<pan$325f3$70a576a8$3150c04a$26db7b31@invalid.invalid>
<ugagv6$2vs64$1@dont-email.me>
<pan$21acb$49c8a2a6$a1bbf038$1e40c8f0@invalid.invalid>
<ugck5i$3faav$1@dont-email.me>
<pan$19122$eaff5f26$f64222cd$d70e555c@invalid.invalid>
<ugd37f$3ln97$2@dont-email.me>
<pan$c64d0$8c0ed5b8$62596621$789ec9e7@invalid.invalid>
<86zg0k8u3l.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 15 Oct 2023 17:18:29 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="87152a8035316740d6ac7a66237ccfef";
logging-data="630393"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/5UrH5SX2piyxG9D9qjEG0tdr4tl/fviA="
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:o4Jc9aMp5MIQOChFGehA5Mtl1e0=
X-Face: Llanfair­pwllgwyngyll­gogery­chwyrnÂ
­drobwll­llan
? ?­tysilio­gogo­goch
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACh0lEQVRYw71Z21bD
MAzzevbfkr4cHjrSXJyL044+MDa6WLEl2SkvkrZ1AbAvXO+bUGSCPYnsuIVGMpm
ZLnjX718GhAKNsp8lON2F9VrhELwIgJlBepkZjA78rVK+FkmNhEJK76UsJlz8+E
rJsjrpYouhLo/SC6qPHgakFOR8wV9+8rCfO/I/oVnmUZUp42/LW2XkLj9TCFNM9
jp5g2EmHZgpYZjCOkYU7sXVogRylJqpdggoFLG1g09Flah/7kErCxzR9HgXPYsq
0glb9cxjIz2Vsk9AmAoCSxECpD713joMKjQqLAtmMqJmXjdVvlMnMQCVITotJd1
z+fh1f1NNo+vuc1KnhWUmY7t03vydTud9BbXCtN3L2PL3bK7JCNG0GHzuZxafyB
fxevCxpm1vrwZltqw6SILCcdoCE6PGQC8wZWDA9Or7Qp5s3lAZezys0nDazs9S9
R0TjwEiksRxLkNPC1NMMWPs1bj0Ei0Yuo+JVtFLuzP1NRJ16qXWN8DhhtmS4PDg
O6mqRxs4bEJrYt087mSIow/1VzW2oFlMQuiuIy/KsUagvhdw6hSjJGlIavbLF8x
j3X47bccLcUSi0dkWh1nUZNhANT1tHKUXrNxNLbd9KPb9wDDVrKwmPQMOPQ1oy6
k5I1DwzDeRJd3jVIhDAUxq3ngzJG4CCkNXZxZVMcjefoK2J0gUY2S3rxz/RuTFx
2zHd9U+obimJXMG4edsk/2j5pTU5G1MmzbRLxkfq5EiT1GGsidvMGzi+1goGb2l
GCrN+nGnV8xj3q3JLRDVPL96vUc7Z4aJ3TN1mVqWAMJMfG+Jxh6TQqP+92iZkCU
xtglds1AB6r0aiSHKcnFck+p/c/0CbacFLQcajGcAAAAASUVORK5CYII=
 by: Blue-Maned_Hawk - Sun, 15 Oct 2023 17:18 UTC

Tim Rentsch wrote:

> The word obsolete means no longer used or no longer useful. If someone
> is still using it then by definition it is not obsolete.

That is not my definition. I consider something obsolete when it has been
replaced.

--

Re: portable way to get highest bit set?

<20231015201922.4b952e264db3cb71dacb8f7a@gmail.moc>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29913&group=comp.lang.c#29913

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton....@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 20:19:22 +0300
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <20231015201922.4b952e264db3cb71dacb8f7a@gmail.moc>
References: <ug5gvh$1jkar$3@dont-email.me>
<20231011102714.44a870af4dfe68f756974953@g{oogle}mail.com>
<ug6huc$1rvp1$1@dont-email.me>
<86h6mxawqq.fsf@linuxsc.com>
<20231012111100.272c96b3209baad26a150e55@g{oogle}mail.com>
<86cyxkb2ka.fsf@linuxsc.com>
<20231012141719.99f5a10ec921db3ee6f7d948@g{oogle}mail.com>
<864jiwaqic.fsf@linuxsc.com>
<20231012173021.0000149c@yahoo.com>
<86v8bbanjv.fsf@linuxsc.com>
<20231015124603.00004072@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="ffa43a3eead92fe52c92d62388865487";
logging-data="661181"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/12VOIksIFI1TkcI+LtWQuET5k//eIbQw="
Cancel-Lock: sha1:PHPlYIfzMf4VlaMXm5IWMKpyPcw=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Sun, 15 Oct 2023 17:19 UTC

Michael S:

> Turned out that people that read this group through
> Eternal September had never seen my answer from ~3 days
> ago. Right now ES spam filter is rather unpredictable and
> appear to suffer both from insufficient strictness and
> from false positives. i2pm2 spam filter is considerably
> better Anyway, I'd post my reply again below.

I had read it vie E.-S. the first time around, which was
several days ago.

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: portable way to get highest bit set?

<86cyxf91b8.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29914&group=comp.lang.c#29914

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 11:40:27 -0700
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <86cyxf91b8.fsf@linuxsc.com>
References: <ug5gvh$1jkar$3@dont-email.me> <pan$e0805$faa9a91a$a60476dc$4a90cfa8@invalid.invalid> <87h6mwu9rk.fsf@nosuchdomain.example.com> <pan$325f3$70a576a8$3150c04a$26db7b31@invalid.invalid> <ugagv6$2vs64$1@dont-email.me> <pan$21acb$49c8a2a6$a1bbf038$1e40c8f0@invalid.invalid> <ugck5i$3faav$1@dont-email.me> <pan$19122$eaff5f26$f64222cd$d70e555c@invalid.invalid> <ugd37f$3ln97$2@dont-email.me> <pan$c64d0$8c0ed5b8$62596621$789ec9e7@invalid.invalid> <86zg0k8u3l.fsf@linuxsc.com> <pan$b29a$e4923427$117477d2$1f9519d0@invalid.invalid>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="eb478ed0db5b06d993c3ccd040701c7e";
logging-data="699465"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PhdG+2V2wrm8+pIPxBzHtJwuIUzUNj2Y="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:ippIhgsMVHJjEbT+umx6ogXh9iM=
sha1:PjmRCOH6nhmcFmDfSoATMqnQxvM=
 by: Tim Rentsch - Sun, 15 Oct 2023 18:40 UTC

Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> writes:

> Tim Rentsch wrote:
>
>> The word obsolete means no longer used or no longer useful. If someone
>> is still using it then by definition it is not obsolete.
>
> That is not my definition. [...]

You are free of course to use any definition you want. If however you
want to be understood then I generally recommend using a dictionary
definition, which is what the one I gave is.

Re: portable way to get highest bit set?

<87v8b7d8yw.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29915&group=comp.lang.c#29915

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 19:41:27 +0100
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <87v8b7d8yw.fsf@bsb.me.uk>
References: <ug5gvh$1jkar$3@dont-email.me>
<20231011102714.44a870af4dfe68f756974953@g{oogle}mail.com>
<ug6huc$1rvp1$1@dont-email.me> <86h6mxawqq.fsf@linuxsc.com>
<20231012111100.272c96b3209baad26a150e55@g{oogle}mail.com>
<86cyxkb2ka.fsf@linuxsc.com>
<20231012141719.99f5a10ec921db3ee6f7d948@g{oogle}mail.com>
<864jiwaqic.fsf@linuxsc.com> <20231012173021.0000149c@yahoo.com>
<86v8bbanjv.fsf@linuxsc.com> <20231015124603.00004072@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5c6816c4bd32002a6f31929cd37c0f96";
logging-data="697828"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19QCoN0KaHOOaTPEbQeKz1xR453+r74JSM="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:NX64WQfCspSwQ4NNu4qYCKz+NL8=
sha1:xU6RgEwBEeKhm7LQXLVxyzwRGM4=
X-BSB-Auth: 1.f6a165956f80e26d6734.20231015194127BST.87v8b7d8yw.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 15 Oct 2023 18:41 UTC

Michael S <already5chosen@yahoo.com> writes:

> Turned out that people that read this group through Eternal September
> had never seen my answer from ~3 days ago.

I read from ES and I saw it.

> Right now ES spam filter is
> rather unpredictable and appear to suffer both from insufficient
> strictness and from false positives.

I don't think the filter would have touched it.

--
Ben.

Re: portable way to get highest bit set?

<pan$1c8ad$baf8f0ef$126a1065$1e71d904@invalid.invalid>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29918&group=comp.lang.c#29918

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: bluemane...@invalid.invalid (Blue-Maned_Hawk)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 20:57:45 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <pan$1c8ad$baf8f0ef$126a1065$1e71d904@invalid.invalid>
References: <ug5gvh$1jkar$3@dont-email.me>
<pan$e0805$faa9a91a$a60476dc$4a90cfa8@invalid.invalid>
<87h6mwu9rk.fsf@nosuchdomain.example.com>
<pan$325f3$70a576a8$3150c04a$26db7b31@invalid.invalid>
<ugagv6$2vs64$1@dont-email.me>
<pan$21acb$49c8a2a6$a1bbf038$1e40c8f0@invalid.invalid>
<ugck5i$3faav$1@dont-email.me>
<pan$19122$eaff5f26$f64222cd$d70e555c@invalid.invalid>
<ugd37f$3ln97$2@dont-email.me>
<pan$c64d0$8c0ed5b8$62596621$789ec9e7@invalid.invalid>
<86zg0k8u3l.fsf@linuxsc.com>
<pan$b29a$e4923427$117477d2$1f9519d0@invalid.invalid>
<86cyxf91b8.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 15 Oct 2023 20:57:45 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="87152a8035316740d6ac7a66237ccfef";
logging-data="757968"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18XtH9srCY9YzhsSCpK3egF9r4pDp1OEVs="
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:2H6Qje6VI+xTd6SGeHAswcxE53E=
X-Face: Llanfair­pwllgwyngyll­gogery­chwyrnÂ
­drobwll­llan
? ?­tysilio­gogo­goch
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACh0lEQVRYw71Z21bD
MAzzevbfkr4cHjrSXJyL044+MDa6WLEl2SkvkrZ1AbAvXO+bUGSCPYnsuIVGMpm
ZLnjX718GhAKNsp8lON2F9VrhELwIgJlBepkZjA78rVK+FkmNhEJK76UsJlz8+E
rJsjrpYouhLo/SC6qPHgakFOR8wV9+8rCfO/I/oVnmUZUp42/LW2XkLj9TCFNM9
jp5g2EmHZgpYZjCOkYU7sXVogRylJqpdggoFLG1g09Flah/7kErCxzR9HgXPYsq
0glb9cxjIz2Vsk9AmAoCSxECpD713joMKjQqLAtmMqJmXjdVvlMnMQCVITotJd1
z+fh1f1NNo+vuc1KnhWUmY7t03vydTud9BbXCtN3L2PL3bK7JCNG0GHzuZxafyB
fxevCxpm1vrwZltqw6SILCcdoCE6PGQC8wZWDA9Or7Qp5s3lAZezys0nDazs9S9
R0TjwEiksRxLkNPC1NMMWPs1bj0Ei0Yuo+JVtFLuzP1NRJ16qXWN8DhhtmS4PDg
O6mqRxs4bEJrYt087mSIow/1VzW2oFlMQuiuIy/KsUagvhdw6hSjJGlIavbLF8x
j3X47bccLcUSi0dkWh1nUZNhANT1tHKUXrNxNLbd9KPb9wDDVrKwmPQMOPQ1oy6
k5I1DwzDeRJd3jVIhDAUxq3ngzJG4CCkNXZxZVMcjefoK2J0gUY2S3rxz/RuTFx
2zHd9U+obimJXMG4edsk/2j5pTU5G1MmzbRLxkfq5EiT1GGsidvMGzi+1goGb2l
GCrN+nGnV8xj3q3JLRDVPL96vUc7Z4aJ3TN1mVqWAMJMfG+Jxh6TQqP+92iZkCU
xtglds1AB6r0aiSHKcnFck+p/c/0CbacFLQcajGcAAAAASUVORK5CYII=
 by: Blue-Maned_Hawk - Sun, 15 Oct 2023 20:57 UTC

Tim Rentsch wrote:

> You are free of course to use any definition you want. If however you
> want to be understood then I generally recommend using a dictionary
> definition, which is what the one I gave is.

The dictionary is not an arbiter of truth.

--

Re: portable way to get highest bit set?

<20231016003510.ae0402a6d402c49449ef8319@gmail.moc>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29919&group=comp.lang.c#29919

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton....@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Mon, 16 Oct 2023 00:35:10 +0300
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <20231016003510.ae0402a6d402c49449ef8319@gmail.moc>
References: <ug5gvh$1jkar$3@dont-email.me>
<pan$e0805$faa9a91a$a60476dc$4a90cfa8@invalid.invalid>
<87h6mwu9rk.fsf@nosuchdomain.example.com>
<pan$325f3$70a576a8$3150c04a$26db7b31@invalid.invalid>
<ugagv6$2vs64$1@dont-email.me>
<pan$21acb$49c8a2a6$a1bbf038$1e40c8f0@invalid.invalid>
<ugck5i$3faav$1@dont-email.me>
<pan$19122$eaff5f26$f64222cd$d70e555c@invalid.invalid>
<ugd37f$3ln97$2@dont-email.me>
<pan$c64d0$8c0ed5b8$62596621$789ec9e7@invalid.invalid>
<86zg0k8u3l.fsf@linuxsc.com>
<pan$b29a$e4923427$117477d2$1f9519d0@invalid.invalid>
<86cyxf91b8.fsf@linuxsc.com>
<pan$1c8ad$baf8f0ef$126a1065$1e71d904@invalid.invalid>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="ffa43a3eead92fe52c92d62388865487";
logging-data="774771"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fHk6NJVRuthPjzAlmDE+I7c38lnLcBds="
Cancel-Lock: sha1:cxSaWW+paEuprelAfVbKQB0z80Q=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Sun, 15 Oct 2023 21:35 UTC

Blue-Maned_Hawk:

> The dictionary is not an arbiter of truth.

Man, it is the arbiter of word meanings, necessary for us to
understand each other. If for some reason you need to use a
common word with your personal definition, give that definition
up front, lest there be a disagreeent of terms.

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: portable way to get highest bit set?

<87v8b7qrv0.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29922&group=comp.lang.c#29922

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 18:27:15 -0700
Organization: None to speak of
Lines: 19
Message-ID: <87v8b7qrv0.fsf@nosuchdomain.example.com>
References: <ug5gvh$1jkar$3@dont-email.me>
<pan$e0805$faa9a91a$a60476dc$4a90cfa8@invalid.invalid>
<87h6mwu9rk.fsf@nosuchdomain.example.com>
<pan$325f3$70a576a8$3150c04a$26db7b31@invalid.invalid>
<ugagv6$2vs64$1@dont-email.me>
<pan$21acb$49c8a2a6$a1bbf038$1e40c8f0@invalid.invalid>
<ugck5i$3faav$1@dont-email.me>
<pan$19122$eaff5f26$f64222cd$d70e555c@invalid.invalid>
<ugd37f$3ln97$2@dont-email.me>
<pan$c64d0$8c0ed5b8$62596621$789ec9e7@invalid.invalid>
<86zg0k8u3l.fsf@linuxsc.com>
<pan$b29a$e4923427$117477d2$1f9519d0@invalid.invalid>
<86cyxf91b8.fsf@linuxsc.com>
<pan$1c8ad$baf8f0ef$126a1065$1e71d904@invalid.invalid>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="f695517c87ebab0c1f10d61121f5b926";
logging-data="864047"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+XPJRvcV4Z4zLbglTR75GV"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:t5AWTrxGuNAPShbWcgOPjdDpMFU=
sha1:93Kvxjn98CDI0UP0ztfUuxQzYsI=
 by: Keith Thompson - Mon, 16 Oct 2023 01:27 UTC

Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> writes:
> Tim Rentsch wrote:
>
>> You are free of course to use any definition you want. If however you
>> want to be understood then I generally recommend using a dictionary
>> definition, which is what the one I gave is.
>
> The dictionary is not an arbiter of truth.

Nor are you.

The truth is, many people have perfectly valid reasons *not* to
upgrade immediately to the latest version of the standard (or of
anything else).

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: portable way to get highest bit set?

<86zg0j6y2h.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29924&group=comp.lang.c#29924

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 20:33:26 -0700
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <86zg0j6y2h.fsf@linuxsc.com>
References: <ug5gvh$1jkar$3@dont-email.me> <pan$e0805$faa9a91a$a60476dc$4a90cfa8@invalid.invalid> <87h6mwu9rk.fsf@nosuchdomain.example.com> <pan$325f3$70a576a8$3150c04a$26db7b31@invalid.invalid> <ugagv6$2vs64$1@dont-email.me> <pan$21acb$49c8a2a6$a1bbf038$1e40c8f0@invalid.invalid> <ugck5i$3faav$1@dont-email.me> <pan$19122$eaff5f26$f64222cd$d70e555c@invalid.invalid> <ugd37f$3ln97$2@dont-email.me> <pan$c64d0$8c0ed5b8$62596621$789ec9e7@invalid.invalid> <86zg0k8u3l.fsf@linuxsc.com> <pan$b29a$e4923427$117477d2$1f9519d0@invalid.invalid> <86cyxf91b8.fsf@linuxsc.com> <pan$1c8ad$baf8f0ef$126a1065$1e71d904@invalid.invalid>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="d7a993245ee191f5bfe23a1c502abceb";
logging-data="1034023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+e6eBBIuAiv6f9jA4i85j04sfwt7TZshs="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:nKXxr8PZGDJ3FhueJ2a357R3mUs=
sha1:kMvBqRH1LjOqcrGsdXBR0VO6SJ4=
 by: Tim Rentsch - Mon, 16 Oct 2023 03:33 UTC

Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> writes:

> Tim Rentsch wrote:
>
>> You are free of course to use any definition you want. If however you
>> want to be understood then I generally recommend using a dictionary
>> definition, which is what the one I gave is.
>
> The dictionary is not an arbiter of truth.

I didn't say it is. It's just a better choice in most cases
if you want other people to understand you. If you don't
care about that, by all means keep doing what you have been
doing.

Re: portable way to get highest bit set?

<ugiboc$vne1$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29925&group=comp.lang.c#29925

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 23:47:24 -0400
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <ugiboc$vne1$1@dont-email.me>
References: <ug5gvh$1jkar$3@dont-email.me>
<pan$e0805$faa9a91a$a60476dc$4a90cfa8@invalid.invalid>
<87h6mwu9rk.fsf@nosuchdomain.example.com>
<pan$325f3$70a576a8$3150c04a$26db7b31@invalid.invalid>
<ugagv6$2vs64$1@dont-email.me>
<pan$21acb$49c8a2a6$a1bbf038$1e40c8f0@invalid.invalid>
<878r86rw6y.fsf@nosuchdomain.example.com>
<pan$ccd5a$be70d7a6$e3ed688b$9880acc4@invalid.invalid>
<ugecsv$3u3so$1@dont-email.me>
<pan$b036e$461431b2$2bf7b043$d730da9d@invalid.invalid>
<ugf7og$3ruq$1@dont-email.me>
<pan$93111$74afa426$cc67762$31ab3c2b@invalid.invalid>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 16 Oct 2023 03:47:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="488f1f992c1470c99c5846f1006d6bf1";
logging-data="1039809"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+0psTu2dpkoMrpWhaTd1Alv3n7aQUfIM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:v4mP7GVBLwxeD4JPFqTC0AOIAbQ=
Content-Language: en-US
In-Reply-To: <pan$93111$74afa426$cc67762$31ab3c2b@invalid.invalid>
 by: James Kuyper - Mon, 16 Oct 2023 03:47 UTC

On 10/15/23 12:57, Blue-Maned_Hawk wrote:
> James Kuyper wrote:
>
>> If the users of those toolchains aren't interested in using newer
>> versions, how is that a problem?
>
> They are intentionally choosing to use obsolete versions.

I repeat - how is that a problem? That's their choice. What version of
any program to use is for each user to decide for themselves - it's
often better to use an older version that you're more familiar than to
always rush ahead to adopt the latest version. What business is it of
yours to decide that they are wrong?
However, whether or not that's a good decision is irrelevant. The fact
that it's a common and popular decision is relevant. Because it has
historically been commonplace for it to take many years for a new
version of C to be adopted, we can reasonably assume that that will
continue to be the case. As a result, code which depends upon features
introduced in the latest version of C will always remain less portable
than code which does, for many years after that version gets approved.

I say this as a early adopter - I started writing C90 code as soon as I
got access to a compiler which supported it (which was many years after
it was approved), and was rather annoyed that it took so long. I would
have done the same with C99, but I was working for a company whose
contract with our client mandated use of C90 (or versions of COBOL or
FORTRAN of comparable vintage - I no longer remember which versions they
were). For code I wrote at home for personal use, I started using C99 as
soon as, and to the extant that, gcc supported it.

Re: portable way to get highest bit set?

<ugic2h$vne1$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29926&group=comp.lang.c#29926

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Sun, 15 Oct 2023 23:52:49 -0400
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <ugic2h$vne1$2@dont-email.me>
References: <ug5gvh$1jkar$3@dont-email.me>
<pan$e0805$faa9a91a$a60476dc$4a90cfa8@invalid.invalid>
<87h6mwu9rk.fsf@nosuchdomain.example.com>
<pan$325f3$70a576a8$3150c04a$26db7b31@invalid.invalid>
<ugagv6$2vs64$1@dont-email.me>
<pan$21acb$49c8a2a6$a1bbf038$1e40c8f0@invalid.invalid>
<ugck5i$3faav$1@dont-email.me>
<pan$19122$eaff5f26$f64222cd$d70e555c@invalid.invalid>
<ugd37f$3ln97$2@dont-email.me>
<pan$c64d0$8c0ed5b8$62596621$789ec9e7@invalid.invalid>
<86zg0k8u3l.fsf@linuxsc.com>
<pan$b29a$e4923427$117477d2$1f9519d0@invalid.invalid>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 16 Oct 2023 03:52:54 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="488f1f992c1470c99c5846f1006d6bf1";
logging-data="1039809"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/vZsstevrEyI0cAcGddt2KYhUhoAIyzIo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:kKoeq3H1byU8kjUehxEe+NWZ3uI=
Content-Language: en-US
In-Reply-To: <pan$b29a$e4923427$117477d2$1f9519d0@invalid.invalid>
 by: James Kuyper - Mon, 16 Oct 2023 03:52 UTC

On 10/15/23 13:18, Blue-Maned_Hawk wrote:
> Tim Rentsch wrote:
>
>> The word obsolete means no longer used or no longer useful. If someone
>> is still using it then by definition it is not obsolete.
>
> That is not my definition. I consider something obsolete when it has been
> replaced.

That's still not the case. C90 has not yet been fully replaced, not even
by C99, much less by later versions - there's still people out there
demanding implementations to support that version of the standard, and
most do. C90 hasn't been the official C version as far as ISO is
concerned for 24 years now, but as far as actual use of the language is
concerned, C90 continues to be used in parallel with all of the other
later versions.

Re: portable way to get highest bit set?

<ugin3m$18er3$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29929&group=comp.lang.c#29929

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: portable way to get highest bit set?
Date: Mon, 16 Oct 2023 09:01:09 +0200
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <ugin3m$18er3$1@dont-email.me>
References: <ug5gvh$1jkar$3@dont-email.me>
<pan$e0805$faa9a91a$a60476dc$4a90cfa8@invalid.invalid>
<87h6mwu9rk.fsf@nosuchdomain.example.com>
<pan$325f3$70a576a8$3150c04a$26db7b31@invalid.invalid>
<ugagv6$2vs64$1@dont-email.me>
<pan$21acb$49c8a2a6$a1bbf038$1e40c8f0@invalid.invalid>
<ugck5i$3faav$1@dont-email.me>
<pan$19122$eaff5f26$f64222cd$d70e555c@invalid.invalid>
<ugd37f$3ln97$2@dont-email.me>
<pan$c64d0$8c0ed5b8$62596621$789ec9e7@invalid.invalid>
<86zg0k8u3l.fsf@linuxsc.com>
<pan$b29a$e4923427$117477d2$1f9519d0@invalid.invalid>
<ugic2h$vne1$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 16 Oct 2023 07:01:10 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6d23bfd38b2d0f8b3e67731f9b03bf80";
logging-data="1325923"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19lqi6Yhfmh0yVSccgKJqYNW6g8FHnJMPM="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:ZSeEfOPlFsWwXw166qJLz2u6TEE=
Content-Language: en-GB
In-Reply-To: <ugic2h$vne1$2@dont-email.me>
 by: David Brown - Mon, 16 Oct 2023 07:01 UTC

On 16/10/2023 05:52, James Kuyper wrote:
> On 10/15/23 13:18, Blue-Maned_Hawk wrote:
>> Tim Rentsch wrote:
>>
>>> The word obsolete means no longer used or no longer useful. If someone
>>> is still using it then by definition it is not obsolete.
>>
>> That is not my definition. I consider something obsolete when it has been
>> replaced.
>
> That's still not the case. C90 has not yet been fully replaced, not even
> by C99, much less by later versions - there's still people out there
> demanding implementations to support that version of the standard, and
> most do. C90 hasn't been the official C version as far as ISO is
> concerned for 24 years now, but as far as actual use of the language is
> concerned, C90 continues to be used in parallel with all of the other
> later versions.
>

Agreed.

There is also, for each version of the C standards, code whose meaning
changes when viewed by newer standards. While the C committee take
great pains to minimise incompatibilities, some still exist. So if you
have code that is perfectly good C90 code, but either different syntax
or semantics in C99 (perhaps you use "restrict" as a variable name),
then C90 is not "obsolete" for that code by any useful definition of the
word.


devel / comp.lang.c / Re: portable way to get highest bit set?

Pages:12345678
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor