home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!stanford.edu!rpal.rockwell.com!planets!sho
- From: sho@planets.risc.rockwell.com (Sho Kuwamoto)
- Subject: Re: (Q) Need bit manipulation algorithm
- Message-ID: <1993Jan6.032113.597@planets.risc.rockwell.com>
- Reply-To: sho@risc.rockwell.com (Sho Kuwamoto)
- Organization: Rockwell International Science Center, Thousand Oaks, Ca.
- References: <1993Jan6.022430.19469@leland.Stanford.EDU>
- Date: Wed, 6 Jan 93 03:21:13 GMT
- Lines: 25
-
- In article <1993Jan6.022430.19469@leland.Stanford.EDU> felciano@summit.stanford.edu (Ramon M. Felciano) writes:
- >So: I need an algorithm that will find a consistent fuzzy match by
- >subtracting bits. It needs to deal with ambiguities like #9 and #10.
- >Thus if two matches have 90% of the bits in common, I need both of
- >them back, one after the other (the order doesn't matter).
-
- Maybe not the fastest method, but a simple one:
- 1) come up with an algorithm which counts the number of
- 1's in a given bit pattern. You'll either use a loop
- with shifts and increments in it, or you'll use masks.
-
- for each pattern,
- 2) bitwise xor your input with the pattern.
- 3) count the number of 1's which result.
-
- 4) return those patterns which yield the smallest sums.
-
- Remember that for step 3, you can stop counting when the
- number of 1's exceeds that of the optimal pattern
- encountered up to that point.
-
- -Sho
- --
- sho@physics.purdue.edu
- sho@risc.rockwell.com
-