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 is

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 base-two

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 the strings and

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 = 00101100;

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 warnings; use

Re: comparing two binary numbers

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

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