Binary Decimals in Python

Patrick Maupin pmaupin at gmail.com
Tue Mar 30 11:28:50 EDT 2010


On Mar 30, 10:13 am, aditya <bluemangrou... at gmail.com> wrote:
> To get the decimal representation of a binary number, I can just do
> this:
>
> int('11',2) # returns 3
>
> But decimal binary numbers throw a ValueError:
>
> int('1.1',2) # should return 1.5, throws error instead.
>
> Is this by design? It seems to me that this is not the correct
> behavior.
>
> - Aditya

So, why should int('1.1', 2) throw an error when int('1.1') doesn't?

Regards,
Pat



More information about the Python-list mailing list