Mr.SpOOn wrote:
Salve, esiste qualche metodo per stampare i primi N numeri in forma binaria? E la possibilità di stamparli con un numero fissato di bit?Ad esempio: il numero 2 è uguale a 10. E' possibile rappresentarlo con 5 bit, cioè: 00010?
>>> nbits=16 >>> num=2837 >>> ''.join(str((num>>b)%2) for b in reversed(range(nbits))) '0000101100010101'>>>
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python