[Tutor] Convert integer number to binary representation

John Fouhy john at fouhy.net
Fri Nov 25 01:46:07 CET 2005


On 25/11/05, Alberto Troiano <alberto.troiano at gmail.com> wrote:
> I want to know how can I convert an integer number to a binary number.
> Like this example:

Hi Alberto,

There's no builtin function to do this (like there is for hex or oct).
 There are a few recipes in the Cookbook on ActiveState that will do
base conversion --- here's a simple one for binary numbers that takes
advantage of the correspondence between binary and hexidecimal
representations of numbers:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440528

--
John.


More information about the Tutor mailing list