Binary Decimals in Python
bluemangroupie at gmail.com
Tue Mar 30 17:54:43 CEST 2010
On Mar 30, 10:37 am, Benjamin Kaplan <benjamin.kap... at case.edu> wrote:
> On Tue, Mar 30, 2010 at 11: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
> > --
> Because int stands for integer and 1.1 is not an integer. You get the
> same error if you try doing int('1.1')
That makes sense. The closest thing I've found is this question on
It seems to me that adding a conversion feature to floats would be a
lot more intuitive.
More information about the Python-list