Index
Home
About
Blog
From: mccalpin@gmp246.austin.ibm.com (McCalpin)
Newsgroups: comp.arch,comp.sys.dec,comp.unix.aix
Subject: Re: Can POWER4, 5 etc continue where Alpha was stopped?
Date: 29 Aug 2001 00:03:44 GMT
In article <bruce-AD55D9.22144128082001@news.akl.ihug.co.nz>,
Bruce Hoult <bruce@hoult.org> wrote:
>In article <9mgps0$12ee$1@ausnews.austin.ibm.com>,
>mccalpin@austin.ibm.com wrote:
>
>> , and [I] have only found
>> one use for [pop count] in my own experience..... (It is a very easy way
>> to determine if an integer is a power of two -- though I don't
>> usually care about how long it takes to make this determination.)
>
>It's not needed for that -- (x & (x-1)) is zero IFF x is a power of two
>(or zero). It works by clearing the least significant set bit.
Ouch -- that sort of bit twiddling makes my poor Fortran brain
hurt. I hate it when I run across coding like this.
>I'm sure you knew this.
I did not know it, but I am trying to forget it as fast as I can!
--
John D. McCalpin, Ph.D. mccalpin@austin.ibm.com
Senior Technical Staff Member IBM POWER Microprocessor Development
"I am willing to make mistakes as long as
someone else is willing to learn from them."
From: Bruce Hoult <bruce@hoult.org>
Newsgroups: comp.arch,comp.sys.dec,comp.unix.aix
Subject: Re: Can POWER4, 5 etc continue where Alpha was stopped?
Date: Wed, 29 Aug 2001 03:27:56 +1200
In article <9mhbh0$pbq$1@ausnews.austin.ibm.com>,
mccalpin@gmp246.austin.ibm.com (McCalpin) wrote:
> In article <bruce-AD55D9.22144128082001@news.akl.ihug.co.nz>,
> Bruce Hoult <bruce@hoult.org> wrote:
> >In article <9mgps0$12ee$1@ausnews.austin.ibm.com>,
> >mccalpin@austin.ibm.com wrote:
> >
> >> , and [I] have only found
> >> one use for [pop count] in my own experience..... (It is a very easy
> >> way
> >> to determine if an integer is a power of two -- though I don't
> >> usually care about how long it takes to make this determination.)
> >
> >It's not needed for that -- (x & (x-1)) is zero IFF x is a power of two
> >(or zero). It works by clearing the least significant set bit.
>
> Ouch -- that sort of bit twiddling makes my poor Fortran brain
> hurt. I hate it when I run across coding like this.
I wouldn't want to see it uncommented somewhere, but it's a perfectly
fine thing to have smewhere in an (inline) function called
IsPowerOfTwo().
-- Bruce
Index
Home
About
Blog