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 #34215 is a reply to message #34069] Thu, 20 February 2003 07:24 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Wed, 19 Feb 2003 22:31:32 -0700, Craig Markwardt wrote:


> JD Smith <jdsmith@as.arizona.edu> writes:
>>
>> Here's a reasonably fast implementation of your proposed method for
>> arrays of unsigned longs, to count the highest bit (or rather, the
>> number of leading 0 bits).
>>
>> function leading_zeroes_reg,num
>> num=[num]
>> zeroes=make_array(/BYTE,DIMENSION=size(num,/DIMENSIONS),VALU E=255b)
>> for i=0,31 do begin
>> shft=ishft(num,-(31-i)) AND 1
>> zeroes=(zeroes ne 255b)*zeroes+(zeroes eq 255b)* $
>> ((shft eq 1)*i+(shft ne 1)*255b)
>> endfor
>> return, (zeroes eq 255b)*32+(zeroes ne 255b)*zeroes
>> end
>
> Thanks. Thinking about it further, one could probably do a pretty fast
> look up table on a byte-by-byte basis, similar to the counting-bits
> lookup that you presented initially.
>


Yes, but it wouldn't have the street cred of '7dcd629'XUL.

JD
[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 08:02:13 PDT 2025

Total time taken to generate the page: 1.12185 seconds