howto print binary number
Mensanator
mensanator at aol.com
Wed May 7 16:31:06 EDT 2008
On May 7, 3:13 pm, dmitrey <dmitrey.kros... at scipy.org> 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
More information about the Python-list
mailing list