count of bits set in a long

Peter Miller peter at neccan.oz
Wed Sep 26 09:35:18 AEST 1990


In article <37545 at ut-emx.uucp> nwagner at ut-emx.uucp (Neal R. Wagner) writes:
>
>  I need a fast method to count the number of bits that are set in a 32-bit
>integer on a Sun 3/80 running 4.0.3 SunOS.

HACKMEM 169

you can do it in straight line code, no loop.
A handful of shifts, a couple of subtracts,
and a modulo.  (Hint: modulo 63)

Look in the X11 sample server sources.  Grep for "HACKMEM".
D#! rnews 1014
Newsgroups: dcs.general
Path: anucsd!anucsd!daw
From: daw at anucsd.anu.oz.au (David Wanless)
Subject: Seamail - Wilderness diaries and calendars
Message-ID: <daw.654311041 at anucsd>
Sender: news at anucsd.anu.oz.au (USENET News software)
Organization: ANU Department of Computer Science
Distribution: dcs
Date: 26 Sep 90 01:04:01 GMT

Wondering what to send to your overseas colleagues and relatives for
Christmas (knowing that seamail postage deadlines are fast approaching) ?
Why not send them an Australian wilderness calendar or diary ?  Wilderness
Society landscape and wildlife calendars, and ACF diaries, are all profusely
illustrated with beautiful photographs, and all proceeds go towards the
campaigns of TWS and ACF.  If interested, contact me, or
visit the Wilderness Shop in the Griffin Centre in Civic (ph. 249 8011). 

                    David Wanless, 
                    (Room 225, Computer Science Department, 
                     phone 5142 (afternoons),
                     e-mail to daw at anucsd).



More information about the Comp.lang.c mailing list