[Python-ideas] Hexadecimal floating literals

David Mertz mertz at gnosis.cx
Thu Sep 21 16:10:43 EDT 2017


Tablet autocorrect: bit representation of inf and -inf.

On Sep 21, 2017 1:09 PM, "David Mertz" <mertz at gnosis.cx> wrote:

> -1
>
> Writing a floating point literal requires A LOT more knowledge than
> writing a hex integer.
>
> What is the bit length of floats on your specific Python compile? What
> happens if you specify more or less precision than actually available.
> Where is the underflow to subnormal numbers? What is the bit representation
> of information? Nan? -0 vs +0?
>
> There are people who know this and need to know this. But float.fromhex()
> is already available to them. A literal is an attractive nuisance for
> people who almost-but-not-quite understand IEEE-854. I.e. those people who
> named neither Tim Peters nor Mike Cowlishaw.
>
> On Sep 21, 2017 9:48 AM, "Lucas Wiman" <lucas.wiman at gmail.com> wrote:
>
> On Thu, Sep 21, 2017 at 8:23 AM, Victor Stinner <victor.stinner at gmail.com>
> wrote:
>
>> While I was first in favor of extending the Python syntax, I changed
>> my mind. Float constants written in hexadecimal is a (very?) rare use
>> case, and there is already float.fromhex() available.
>>
>> A new syntax is something more to learn when you learn Python. Is it
>> worth it? I don't think so. Very few people need to write hexadecimal
>> constants in their code.
>>
>
> It is inconsistent that you can write hexadecimal integers but not
> floating point numbers. Consistency in syntax is fewer things to learn, not
> more. That said, I agree it's a rare use case, so it probably doesn't
> matter much either way.
>
> - Lucas
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170921/d01c5d19/attachment.html>


More information about the Python-ideas mailing list