Leading 0's syntax error in datetime.date module (Python 3.6)

Peter J. Holzer hjp-python at hjp.at
Sun May 13 17:55:01 EDT 2018


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
| |   | hjp at hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20180513/46f39186/attachment.sig>


More information about the Python-list mailing list