On Mar 30, 8:13 am, aditya <bluemangrou...@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.
The int() constructor returns integers. So, look to float() for non-integral values. Binary representation isn't supported yet, but we do have hex: >>> float.fromhex('1.8') 1.5 Raymond -- http://mail.python.org/mailman/listinfo/python-list