how to compare two number sequences

Discussion in 'C++' started by FC, Mar 4, 2005.

  1. FC

    FC Guest

    Hi all:
    I have two 32 bit long sequence of binary random numbers. When I compare
    them side by side I want to count all the transitions from one to zero,
    and all the transitions from zero to one between the two sequences like
    this:

    01100110101010011010101010011001
    00110110111001100101010111010101
    v ^ ^ v^^vv^v^v^v^ ^ v^

    Where v is when it goes low from the first to the second sequence and ^
    when it goes high.

    So far I have implemented an xor and I can count all the transitions but
    I cannot tell them apart (between high and low). Is there a function or
    a method that will allow me to tell them apart? If I could do this in
    one pass will be even better. Thanks in advance.
     
    FC, Mar 4, 2005
    #1
    1. Advertising

  2. FC

    David Harmon Guest

    On Fri, 04 Mar 2005 00:40:05 -0500 in comp.lang.c++, FC
    <> wrote,
    >I have two 32 bit long sequence of binary random numbers. When I compare
    >them side by side I want to count all the transitions from one to zero,
    >and all the transitions from zero to one


    A & ~B
    B & ~A
     
    David Harmon, Mar 4, 2005
    #2
    1. Advertising

  3. FC

    FC Guest

    David Harmon wrote:
    > On Fri, 04 Mar 2005 00:40:05 -0500 in comp.lang.c++, FC
    > <> wrote,
    >
    >>I have two 32 bit long sequence of binary random numbers. When I compare
    >>them side by side I want to count all the transitions from one to zero,
    >>and all the transitions from zero to one

    >
    >
    > A & ~B
    > B & ~A
    >

    Thanks, that was painless.
     
    FC, Mar 4, 2005
    #3
  4. FC wrote:

    > David Harmon wrote:
    >
    >> On Fri, 04 Mar 2005 00:40:05 -0500 in comp.lang.c++, FC
    >> <> wrote,
    >>
    >>> I have two 32 bit long sequence of binary random numbers. When I
    >>> compare them side by side I want to count all the transitions from
    >>> one to zero, and all the transitions from zero to one

    >>
    >>
    >>
    >> A & ~B
    >> B & ~A
    >>

    > Thanks, that was painless.



    You can also use std::bitset.



    --
    Ioannis Vranos

    http://www23.brinkster.com/noicys
     
    Ioannis Vranos, Mar 4, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan
    Replies:
    3
    Views:
    302
    =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?=
    Jul 25, 2004
  2. Henrik Holm

    Iteration over two sequences

    Henrik Holm, Jan 12, 2005, in forum: Python
    Replies:
    14
    Views:
    496
    Scott David Daniels
    Feb 11, 2005
  3. GenxLogic
    Replies:
    3
    Views:
    1,351
    andrewmcdonagh
    Dec 6, 2006
  4. JMan
    Replies:
    7
    Views:
    479
    Martin Honnen
    Oct 15, 2008
  5. Martin Foster

    Using hashes to sort number sequences

    Martin Foster, May 13, 2004, in forum: Perl Misc
    Replies:
    7
    Views:
    157
    Ben Morrow
    May 13, 2004
Loading...

Share This Page