Re: [CHALLENGE] finding rightmost zero bit - C programmer's take
- From: "Dr Ivan D. Reid" <Ivan.Reid@xxxxxxxxxxxx>
- Date: Tue, 30 Aug 2005 16:00:18 +0000 (UTC)
On Tue, 30 Aug 2005 08:25:47 -0700, glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
wrote in <o8CdnZ2dnZ1Fsx6NnZ2dndfnid6dnZ2dRVn-0Z2dnZ0@xxxxxxxxxxx>:
> N. Shamsundar wrote:
> (snip)
>> for(x=y, i=0; i<32; i++){
>> if(! (x & 1))break;
>> x=x >> 1;
>> }
> It is slightly less simple and slightly less natural in Fortran,
> but not so bad. I have no idea how much optimizing either
> compiler does on it.
> x=y
> do 1 i=0,31
> if(iand(x,1).eq.0) goto 2
> x=ishft(x,-1)
> 1 continue
> 2 continue
Why not
x=y
do i=0,31
if(iand(x,1).eq.0) exit
x=ishft(x,-1)
enddo
....
? Despite my grounding in older FORTRAN I find some of the newer constructs
more readable.
--
Ivan Reid, Electronic & Computer Engineering, ___ CMS Collaboration,
Brunel University. Ivan.Reid@[brunel.ac.uk|cern.ch] Room 40-1-B12, CERN
KotPT -- "for stupidity above and beyond the call of duty".
.
- Follow-Ups:
- Re: [CHALLENGE] finding rightmost zero bit - C programmer's take
- From: Bart Vandewoestyne
- Re: [CHALLENGE] finding rightmost zero bit - C programmer's take
- References:
- [CHALLENGE] finding rightmost zero bit
- From: Bart Vandewoestyne
- Re: [CHALLENGE] finding rightmost zero bit - C programmer's take
- From: N. Shamsundar
- Re: [CHALLENGE] finding rightmost zero bit - C programmer's take
- From: glen herrmannsfeldt
- [CHALLENGE] finding rightmost zero bit
- Prev by Date: Re: [CHALLENGE] finding rightmost zero bit - C programmer's take
- Next by Date: CDC peculiarities (was Re: Undefined array elements)
- Previous by thread: Re: [CHALLENGE] finding rightmost zero bit - C programmer's take
- Next by thread: Re: [CHALLENGE] finding rightmost zero bit - C programmer's take
- Index(es):
Relevant Pages
|