[Tutor] Is there an easy way to conduct binary numbers?

Kent Johnson kent37 at tds.net
Thu Dec 23 20:48:03 CET 2004


Googling in comp.lang.python for "convert binary" gives several solutions including the ones in this
thread:
http://tinyurl.com/6dwom


Juan Shen wrote:
> I have found there are easy functions and options to do basic octal and
> hexadecimal number operation.
> 
> oct(...)
> oct(number) -> string
> 
> Return the octal representation of an integer or long integer.
> 
> hex(...)
> hex(number) -> string
> 
> Return the hexadecimal representation of an integer or long integer.
> 
> print '%o' %number
> Print a decimal number in octal format.
> 
> print '%X' %number
> Print a decimal number in hexadecimal format.
> 
> However, I can't find their binary counterpart, something like bin(...)
> or print '%b'. Binary integer is extremely useful in my
> electronic-related job. So...I need help. Is there any function to
> transform between binary and decimal integers in python's library? If
> not, what's the solution to binary?
> Juan
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


More information about the Tutor mailing list