On May 7, 3:31 pm, Mensanator <[EMAIL PROTECTED]> wrote: > On May 7, 3:13 pm, dmitrey <[EMAIL PROTECTED]> wrote: > > > hi all, > > could you inform how to print binary number? > > I.e. something like > > > print '%b' % my_number > > > it would be nice would it print exactly 8 binary digits (0-1, with > > possible start from 0) > > > Thank you in advance, D > > The gmpy works good. > > >>> import gmpy > >>> print gmpy.digits(66,2).zfill(8) > > 01000010
>>> print '\n'.join( [ ''.join( [ str( a>> i & 1 ) for i in range( 7, -1, -1 ) ] ) for a in range( 10 ) ] ) 00000000 00000001 00000010 00000011 00000100 00000101 00000110 00000111 00001000 00001001 -- http://mail.python.org/mailman/listinfo/python-list