On 2018-05-11 12:32:24 +0100, bartc wrote:
> I tried it in Python 3 (0o100.5 - I find that prefix fiddly to type actually
> as I have to stop and think), and it seems to be illegal.

You could also read the docs.


> Based floating point literals may be unusual, but bear in mind that in
> decimal, some values may not be represented exactly (eg 0.1). I believe that
> in base 2, 4, 8 or 16, any floating point literal can be represented
> exactly, at least up the precision available.

Which is why C has hexadecimal floating point literals.

(And of course "any" is only correct if the internal representation is
binary - in general you don't unexpected rounding errors if the base of
the internal representation and the base of the literal match, and you
do get unexpected rounding errors if they don't)

        hp

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | h...@hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>

Attachment: signature.asc
Description: PGP signature

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to