develooper Front page | perl.beginners | Postings from May 2008

comparing two binary numbers

Thread Next
From:
Johnson Lau
Date:
May 10, 2008 22:09
Subject:
comparing two binary numbers
Dear all,

I need to compare two binary numbers and need perl to return the
number of matching bits.

For example:

$aaa = "10111100";
$bbb = "00101100";

In this case, the number of matching bits is 6.

I know I could split the strings and compare the bits one by one.
However, is there any faster functions for this? I need to compare
millions of such strings with 1000 bits for each.

Thanks a lot!!

Johnson Lau

Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About