Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > How to find lon...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 26095 of 26198
Post > Topic >>

How to find longest bitrange of ones

by longhorn <kplefebvre@[EMAIL PROTECTED] > May 6, 2008 at 08:30 PM

Hello,

I'm looking for a macro that will return the longest range of ones
in an unsigned integer, along with starting and ending position.

For example I have an unsigned int data that looks like:

bit pos: 31 30 29 28 27 26 25 24 23 22 21 20 19 18 ....  00
data      0   1   1  1   1   0  1   1  0   1  0   1  1   0  ...    0

In this case I would get the longest range = 4, start=27, end=30.

Does anyone know a simple way to do this?

Thanks,
Kevin




 3 Posts in Topic:
How to find longest bitrange of ones
longhorn <kplefebvre@[  2008-05-06 20:30:06 
Re: How to find longest bitrange of ones
Peter Nilsson <airia@[  2008-05-06 21:03:43 
Re: How to find longest bitrange of ones
Willem <willem@[EMAIL   2008-05-07 08:44:33 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 19:16:01 CDT 2008.