Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   how to compare two number sequences (http://www.velocityreviews.com/forums/t289271-how-to-compare-two-number-sequences.html)

 FC 03-04-2005 05:40 AM

how to compare two number sequences

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.

 David Harmon 03-04-2005 06:37 AM

Re: how to compare two number sequences

On Fri, 04 Mar 2005 00:40:05 -0500 in comp.lang.c++, FC
<fcarpio@NOJUNKcomcast.net> 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

 FC 03-04-2005 11:44 AM

Re: how to compare two number sequences

David Harmon wrote:
> On Fri, 04 Mar 2005 00:40:05 -0500 in comp.lang.c++, FC
> <fcarpio@NOJUNKcomcast.net> 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.

 Ioannis Vranos 03-04-2005 05:10 PM

Re: how to compare two number sequences

FC wrote:

> David Harmon wrote:
>
>> On Fri, 04 Mar 2005 00:40:05 -0500 in comp.lang.c++, FC
>> <fcarpio@NOJUNKcomcast.net> 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

 All times are GMT. The time now is 06:15 PM.