Article View: comp.compression.research
Article #24Re: Algorithm for finding set bits in a bit-string (and MSB).
From: Alan Bowler
Date: Wed, 05 Aug 1992 21:59
Date: Wed, 05 Aug 1992 21:59
16 lines
1321 bytes
1321 bytes
In article <55926@mentor.cc.purdue.edu> hrubin@pop.stat.purdue.edu (Herman Rubin) writes: >In article <BsFMD4.HAI@watcgl.uwaterloo.ca> awpaeth@watpix.waterloo.edu (Alan Wm Paeth) writes: >>An elegant and efficient MSB-finding algorithm has been forwarded to me by >>Dean Inada (dmi@peregrine.com). It has a constant running time proportional >>to Log2(machine int size): > >This is a good example of > >1. Why the instruction is needed as hardware, if it is important at all; > Actually, on most machines there is hardware to find the most significant bit, although it usually takes a short bit of assembler to take advantage of it. Convert the number to floating point and look at the exponent bits. The optimal seqeunce varies with the hardware in question but it can usually be done in less than 10 instructions.
Technical Details
Message-ID:
<1992Aug5.215915.9787@thinkage.on.ca>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watmath!thinkage!atbowlerReferences:
<1992Aug3.164044.28037@m.cs.uiuc.edu> <BsFMD4.HAI@watcgl.uwaterloo.ca> <55926@mentor.cc.purdue.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.compression.research Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watmath!thinkage!atbowler From: atbowler@thinkage.on.ca (Alan Bowler) Subject: Re: Algorithm for finding set bits in a bit-string (and MSB). Message-ID: <1992Aug5.215915.9787@thinkage.on.ca> Organization: Thinkage Ltd. References: <1992Aug3.164044.28037@m.cs.uiuc.edu> <BsFMD4.HAI@watcgl.uwaterloo.ca> <55926@mentor.cc.purdue.edu> Date: Wed, 5 Aug 1992 21:59:15 GMT Lines: 16