comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: counting bits
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: counting bits [message #34106 is a reply to message #34105] Mon, 17 February 2003 12:38 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Joe Foose (jfoose@ameritech.net) writes:

> In IDL, does anybody have any ideas of how to efficiently count all the bits
> that are set in an array of unsigned long integers? I'm not concerened with
> which bits are set, but just how many. thanks, joe.

Just of the top of my head, wouldn't something like this work:

IDL> total = 0.0
IDL> for j=0,31 do total = TOTAL((array AND 2^j) NE 0)
IDL> print, Fix(total)

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: running out of memory! can all memory be restored in idl?
Next Topic: Re: howto bind shortcut key to button

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 14:44:48 PDT 2025

Total time taken to generate the page: 1.36187 seconds