How can I convert a string of binary digits to a number?
I've got this but I imagine there's some kind of
built-in method. Is there?
def BinStrToNum ( binStr )
sum = 0
digit = 1
binStr.reverse.each_byte { |i|
sum += (i-48)*digit
digit <<= 1
}
return sum
end
Thanks,
Andrew