Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #4021

Re: Fast counting of 1-bits of arbitrarily long bit sequences

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "osmium" <r124c4u102@comcast.net>
Newsgroups comp.programming
Subject Re: Fast counting of 1-bits of arbitrarily long bit sequences
Date Tue, 3 Dec 2013 10:16:22 -0600
Lines 23
Message-ID <bg6eelFb507U1@mid.individual.net> (permalink)
References <l7iish$9p7$1@news.albasani.net> <7q9r99thnsln7i1d09evsdq4c80r4qrvd1@4ax.com>
X-Trace individual.net EpQf+016Tc8CjsWKQvPPuwhNpQcfg4qNAAAp7QDo1IjsQjesyn
Cancel-Lock sha1:/UWtbxf+Z6ujLXok0TkrESekjI4=
X-Priority 3
X-MSMail-Priority Normal
X-Newsreader Microsoft Outlook Express 6.00.2900.2180
X-RFC2646 Format=Flowed; Original
X-MimeOLE Produced By Microsoft MimeOLE V6.00.2900.2180
Xref csiph.com comp.programming:4021

Show key headers only | View raw


"Robert Wessel" wrote:

> On Mon, 02 Dec 2013 19:17:55 +0100, Mok-Kong Shen
> <mok-kong.shen@t-online.de> wrote:
>
>>
>>Given a n-bit sequence, one may be interested to determine the number
>>of 1-bits in it. Decades ago, some computers, e.g. those from CDC, had
>>an instruction delivering the bit count of a computer word, which was
>>commonly believed to have been specially provided to facilitate some
>>crypto studies. A fast software bit counting algorithm for n=32 in C is
>>well-known. In the following is a Python code for arbitrary large
>>values of n, based on the same idea. Hopefully it could be useful for
>>some readers.
>
>
> Many current machines have population count instructions, including
> x86, zSeries, PPC/POWER, ARM...  (Not all versions, of course).

Is there any way to use those instructions in a high-level language such as 
C without resorting to assembly language? 

Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Fast counting of 1-bits of arbitrarily long bit sequences Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-12-02 19:17 +0100
  Re: Fast counting of 1-bits of arbitrarily long bit sequences Robert Wessel <robertwessel2@yahoo.com> - 2013-12-03 03:44 -0600
    Re: Fast counting of 1-bits of arbitrarily long bit sequences "osmium" <r124c4u102@comcast.net> - 2013-12-03 10:16 -0600
      Re: Fast counting of 1-bits of arbitrarily long bit sequences Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-12-03 21:35 +0000
      Re: Fast counting of 1-bits of arbitrarily long bit sequences Robert Wessel <robertwessel2@yahoo.com> - 2013-12-03 15:47 -0600
    Re: Fast counting of 1-bits of arbitrarily long bit sequences Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-12-03 17:31 +0100
      Re: Fast counting of 1-bits of arbitrarily long bit sequences Robert Wessel <robertwessel2@yahoo.com> - 2013-12-03 15:50 -0600
        Re: Fast counting of 1-bits of arbitrarily long bit sequences Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-12-04 16:03 +0100

csiph-web