> Em Quarta 08 Junho 2005 09:38, Guyon Morée escreveu: > > Don't know if this is what you mean, but: > > > > Binary to decimal: > > >>> bin_num = '100001011' > > >>> int(bin_num, 2) > > > > 267 > > Dont know this way of using it. Thanks for the teachings :) > > See ya !
>>> def binary(i): ... ls=[] ... while 1: ... ls.append(i&1) ... i>>=1 ... if i==0: ... break ... return "".join(str(x) for x in reversed(ls)) ... >>> binary(20) '10100' -- http://mail.python.org/mailman/listinfo/python-list