Johnson Lau wrote:
Dear all,
Hello,
I need to compare two binary numbers and need perl to return the
number of matching bits.
For example:
$aaa = 1000;
$bbb = 00101100;
Those aren't binary numbers, they are strings.
perldoc perlnumber
In this case, the number of matching bits is
John W. Krahn schreef:
Johnson Lau:
I need to compare two binary numbers and need perl to return the
number of matching bits. For example:
$aaa = 1000;
$bbb = 00101100;
Those aren't binary numbers, they are strings.
I don't mind reading binary number as some base-two
On 5/11/08, Johnson Lau [EMAIL PROTECTED] wrote:
Dear all,
I need to compare two binary numbers and need perl to return the
number of matching bits.
For example:
$aaa = 1000;
$bbb = 00101100;
In this case, the number of matching bits is 6.
I know I could split the strings and
Johnson Lau schreef:
I need to compare two binary numbers and need perl to return the
number of matching bits.
For example:
$aaa = 1000;
$bbb = 00101100;
In this case, the number of matching bits is 6.
perl -Mstrict -Mwarnings -le'
my $b1 = 1000;
my $b2 = 00101100;
On May 11, 3:09 pm, [EMAIL PROTECTED] (Johnson Lau) wrote:
Dear all,
I need to compare two binary numbers and need perl to return the
number of matching bits.
For example:
$aaa = 1000;
$bbb = 00101100;
In this case, the number of matching bits is 6.
use strict;
use warnings;
use
- Original Message -
From: Johnson Lau [EMAIL PROTECTED]
Newsgroups: perl.beginners
To: beginners@perl.org
Sent: Sunday, May 11, 2008 1:09 AM
Subject: comparing two binary numbers
Dear all,
I need to compare two binary numbers and need perl to return the
number of matching bits
Dear all,
I need to compare two binary numbers and need perl to return the
number of matching bits.
For example:
$aaa = 1000;
$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