Binary to Hex conversions

piet at cs.uu.nl piet at cs.uu.nl
Fri Aug 18 11:53:12 EDT 2000


>>>>> Mike Olson <mro at provis.com> (MO) writes:

MO> How do I convert a binary number to a decimal or hex number?

There are no decimal or hex numbers. And strictly speaking no binary
numbers either. Just binary/decimal/hex representations of numbers (i.e.
strings). 
So what do you want? Do you want to convert a string with a binary
representation of a number to the number or to convert a number to its
decimal or hex representation?

The first can be done with string.atoi, the latter with the % operator.
Or str or repr or `` for decimal, and the hex function for hex.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl



More information about the Python-list mailing list