Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #163329
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Check if all 256 bits are clear or set ? |
| Date | 2021-11-07 00:08 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <87fss86d5g.fsf@bsb.me.uk> (permalink) |
| References | (2 earlier) <sm095i-892.ln1@aretha.foo> <87fssdh302.fsf@bsb.me.uk> <37fh5i-t92.ln1@aretha.foo> <87ilx5a6nf.fsf@bsb.me.uk> <86r1bsc4b7.fsf@linuxsc.com> |
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>
>> i = 0;
>> while (i < n && (unsigned char)~0U == data[i]) i++;
>> // i >= n or data[i] != -1
>> if (i < n)
>> // data[i] != -1
>> clrset ^= ALL_SET;
>>
>> i = 0;
>> while (i < n && 0 == data[i]) i++;
>> // i >= n or data[i] != 0
>> if (i < n)
>> // data[i] != 0
>> clrset ^= ALL_CLEAR;
For the record, not what I would write! I was explaining a point about
loops.
> For fun:
>
> size_t i = -1, clear = 1, set = 1;
> unsigned char ones = -1;
> while( clear | set && ++i < n ){
> clear &= data[i] == 0, set &= data[i] == ones;
> }
> return set<<1 | clear;
>
--
Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Check if all 256 bits are clear or set ? skybuck2000 <skybuck2000@hotmail.com> - 2021-10-28 17:47 -0700
Re: Check if all 256 bits are clear or set ? skybuck2000 <skybuck2000@hotmail.com> - 2021-10-28 18:02 -0700
Re: Check if all 256 bits are clear or set ? skybuck2000 <skybuck2000@hotmail.com> - 2021-10-28 18:12 -0700
Re: Check if all 256 bits are clear or set ? skybuck2000 <skybuck2000@hotmail.com> - 2021-10-28 19:18 -0700
Re: Check if all 256 bits are clear or set ? skybuck2000 <skybuck2000@hotmail.com> - 2021-10-29 05:16 -0700
Re: Check if all 256 bits are clear or set ? Peter 'Shaggy' Haywood <phaywood@alphalink.com.au> - 2021-11-03 11:11 +1100
Re: Check if all 256 bits are clear or set ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-03 11:50 +0000
Re: Check if all 256 bits are clear or set ? Peter 'Shaggy' Haywood <phaywood@alphalink.com.au> - 2021-11-06 16:08 +1100
Re: Check if all 256 bits are clear or set ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-06 11:02 +0000
Re: Check if all 256 bits are clear or set ? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-11-06 15:04 -0700
Re: Check if all 256 bits are clear or set ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-06 22:06 +0000
Re: Check if all 256 bits are clear or set ? Peter 'Shaggy' Haywood <phaywood@alphalink.com.au> - 2021-11-13 11:54 +1100
Re: Check if all 256 bits are clear or set ? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-11-06 15:22 -0700
Re: Check if all 256 bits are clear or set ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-07 00:08 +0000
Re: Check if all 256 bits are clear or set ? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-11-07 08:12 -0800
Re: Check if all 256 bits are clear or set ? skybuck2000 <skybuck2000@hotmail.com> - 2021-11-23 08:23 -0800
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-06 15:01 +0100
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-03 21:04 +0100
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-03 21:09 +0100
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-03 21:11 +0100
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-03 21:25 +0100
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-04 07:05 +0100
Re: Check if all 256 bits are clear or set ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-04 11:37 +0000
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-04 17:58 +0100
Re: Check if all 256 bits are clear or set ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-04 17:13 +0000
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-04 18:15 +0100
Re: Check if all 256 bits are clear or set ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-11-04 17:27 +0000
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-04 18:29 +0100
Re: Check if all 256 bits are clear or set ? scott@slp53.sl.home (Scott Lurndal) - 2021-11-04 17:28 +0000
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-05 11:56 +0100
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-05 18:20 +0100
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-05 18:32 +0100
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-04 18:13 +0100
Re: Check if all 256 bits are clear or set ? Manfred <noname@add.invalid> - 2021-11-04 19:28 +0100
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-04 20:29 +0100
Re: Check if all 256 bits are clear or set ? Manfred <noname@add.invalid> - 2021-11-05 02:06 +0100
Re: Check if all 256 bits are clear or set ? Bonita Montero <Bonita.Montero@gmail.com> - 2021-11-05 08:57 +0100
Re: Check if all 256 bits are clear or set ? Bart <bc@freeuk.com> - 2021-11-04 18:01 +0000
csiph-web