The conversion is not supported for decimal integers AFAIK, however '0b123.456' is always valid. I guess you can always get a decimal number convertor onto Python-recipes<br><br><br><br><div class="gmail_quote">On Tue, Mar 30, 2010 at 9:05 PM, Grant Olson <span dir="ltr"><<a href="mailto:kgo@grant-olson.net">kgo@grant-olson.net</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">On 3/30/2010 11:13 AM, aditya wrote:<br>
> To get the decimal representation of a binary number, I can just do<br>
> this:<br>
><br>
> int('11',2) # returns 3<br>
><br>
> But decimal binary numbers throw a ValueError:<br>
><br>
> int('1.1',2) # should return 1.5, throws error instead.<br>
><br>
> Is this by design? It seems to me that this is not the correct<br>
> behavior.<br>
><br>
<br>
</div>Well technically that would be a 'radix point', not a decimal point.<br>
<br>
But I think the problem is that computers don't store fractional values<br>
that way internally.  They either use floating or fixed point math.  You<br>
would never look at raw binary data on a computer and see something like<br>
'1010.1010', and no one would write it that way, and no language (that I<br>
know of) would accept that as a valid value if you did something like "x<br>
= 0b1010.1010"<br>
<br>
So in that sense, it might not be an intentional oversight, but it's not<br>
a very practical or useful feature.<br>
<div><div></div><div class="h5">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>