Author: Russell Reagan
Date: 12:25:51 01/10/04
Go up one level in this thread
On January 10, 2004 at 14:28:58, Chris Hull wrote: >I am trying to find a fast algorithm that will return the closest bit to a given >bit. I searched google but found nothing. > >Here is an example problem stated as concisely as I can. > >Given: > > 111111 > 5432109876543210 // bit positions > >X = 0101000100000101 // binary >Postion = 8 > >/** Here is the problem we are trying to solve > Find nearest bit higher than bit number 8 and > find nearest bit lower than bit number 8 **/ > >X' = 0101000*00000101 > >so if > >Y = int FindNearestHigherBit( int X, int Position ); >Z = int FindNearestLowerBit( int X, int Position ); > >then > >Y = 0001000000000000 >Z = 0000000000000100 > >So I am looking for the function/algorithm for FindNearestHigherBit and >FindNearestLowerBit. I would like one that runs fast (ie one clock cycle) >and not a loop that looks at every bit. I don't think you're going to find one that runs in one clock cycle, but you can do some of this pretty fast. The FindNearestHigherBit function should run pretty fast (because of the nature of manipulating right-most bits). I will have to have a look in one of my books at home after I get off work, and I should be able to give you some answers. Just out of curiosity, what are you using this for?
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.