[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting a String of bits into a binary number in perl?


 $a="100";  I want to convert this into perl's interpretation of
binary no ie $a=0b100

# perl -wple 's/\b([01]+)\b/"0b$1"/gee'
100
4
10111101010101
12117
the powers of 2 are 1, 10, 100, 1000, 10000, 100000
the powers of 2 are 1, 2, 4, 8, 16, 32


--
"Big discoveries are protected by public incredulity." -- Marshall McLuhan


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.