473,378 Members | 1,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how to compare two number sequences

FC
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.
Jul 23 '05 #1
3 1957
On Fri, 04 Mar 2005 00:40:05 -0500 in comp.lang.c++, FC
<fc*****@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

Jul 23 '05 #2
FC
David Harmon wrote:
On Fri, 04 Mar 2005 00:40:05 -0500 in comp.lang.c++, FC
<fc*****@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.
Jul 23 '05 #3
FC wrote:
David Harmon wrote:
On Fri, 04 Mar 2005 00:40:05 -0500 in comp.lang.c++, FC
<fc*****@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
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: Christian Seberino | last post by:
How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python? Python's design is godly. I'm wondering if Ruby's is godly too. I've heard it has solid OOP design but then...
1
by: Frank | last post by:
Hi, is there a way to use XSL to compare two XML files to verify if a "record" in an XML file has changed of parent in another XML file ? I am trying to implement a template in an XSL stylesheet...
4
by: alexis | last post by:
Hi, In a form I have the curent date <input name="datetoday" type="hidden" value="<? echo date("d/m/Y"); ?>"> and <input type=text name="datebox" size=15> The date format is d/m/Y...
3
by: Matt | last post by:
if (123 > 33) will return true and if ("123" > 33) will return true So my question is, if the above behaviors are the same?? If string is a number, and compare with another number, it will...
62
by: jugaaru | last post by:
How to generate fibonacci mubers in C ?
122
by: Einar | last post by:
Hi, I wonder if there is a nice bit twiddling hack to compare a large number of variables? If you first store them in an array, you can do: for (i = 0; i < n; i++) { if (array != value) {...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
16
by: jason.cipriani | last post by:
I am looking for a random number generator implementation with the following requirements: - Thread-safe, re-entrant. - Produces consistently reproducible sequences of psuedo-random numbers...
12
by: loial | last post by:
I have a requirement to compare 2 text files and write to a 3rd file only those lines that appear in the 2nd file but not in the 1st file. Rather than re-invent the wheel I am wondering if anyone...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.