Re: comparing two binary numbers

2008-05-12 Thread Dr.Ruud
"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

Re: comparing two binary numbers

2008-05-12 Thread John W. Krahn
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 i

Re: comparing two binary numbers

2008-05-11 Thread Chris Charley
- Original Message - From: ""Johnson Lau"" <[EMAIL PROTECTED]> Newsgroups: perl.beginners To: 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 m

Re: comparing two binary numbers

2008-05-11 Thread sisyphus
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

Re: comparing two binary numbers

2008-05-11 Thread Dr.Ruud
"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 =

Re: comparing two binary numbers

2008-05-11 Thread Li, Jialin
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

comparing two binary numbers

2008-05-10 Thread Johnson Lau
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