Counting bits


Closed Thread
Results 1 to 4 of 4

Thread: Counting bits

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi, Russ

    first, shift right your word 12 times if > 4095 ...

    mask the result to keep the 4 lower bits,

    then 6 possibilities remain for an even count of the bits ...

    ( call the result "ABCD" ... if even, ABCD = Ch,Ah,9h,6h,5h or 3h )

    A SELECT CASE will do it.

    mask your word to keep the 4 lower bits

    Then 6 possibilities ...

    The SELECT CASE ...

    it's one way ...in PbP !!! ( lol )


    or use "NCD" function in a loop ... which looks furiously to what Darrel Wrote !!!


    Alain
    Last edited by Acetronics2; - 10th October 2008 at 09:07.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  3. PIC's ports individual bits manipulation - how to?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 38
    Last Post: - 27th February 2007, 22:34
  4. Need clever way to convert 10 bits to 8 bits
    By MikeTamu in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 2nd September 2005, 15:13
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts