Velocity Reviews > C++ > how to compare two number sequences

# how to compare two number sequences

FC
Guest
Posts: n/a

 03-04-2005
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
Guest
Posts: n/a

 03-04-2005
On Fri, 04 Mar 2005 00:40:05 -0500 in comp.lang.c++, FC
<(E-Mail Removed)> 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
Guest
Posts: n/a

 03-04-2005
David Harmon wrote:
> On Fri, 04 Mar 2005 00:40:05 -0500 in comp.lang.c++, FC
> <(E-Mail Removed)> 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
Guest
Posts: n/a

 03-04-2005
FC wrote:

> David Harmon wrote:
>
>> On Fri, 04 Mar 2005 00:40:05 -0500 in comp.lang.c++, FC
>> <(E-Mail Removed)> 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

 Thread Tools

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Edward A. Falk C Programming 1 04-04-2013 08:07 PM GenxLogic Java 3 12-06-2006 08:41 PM Henrik Holm Python 14 02-11-2005 10:24 PM Dan Python 3 07-25-2004 07:19 PM Martin Foster Perl Misc 7 05-13-2004 08:36 PM

Advertisments