[Python-ideas] Hexadecimal floating literals

Thibault Hilaire thibault.hilaire at lip6.fr
Fri Sep 8 05:47:17 EDT 2017


Dear all

This is my very first email to python-ideas, and I strongly support this idea.
float.hex() does the job for float to hexadecimal conversion, and float.fromhex() does the opposite. But a full support for hexadecimal floating-point literals would be great (it bypasses the decimal to floating-point conversion), as explained for general purpose here : http://www.exploringbinary.com/hexadecimal-floating-point-constants/

The support for hexadecimal formatting was introduced in C99 with the '%a' formatter for string formatting (see http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf page 57-58 for literals, or http://en.cppreference.com/w/cpp/language/floating_literal), and, it would be great if python could support it.

Thanks

Thibault 


> The support of hexadecimal floating literals (like 0xC.68p+2) is included in just released C++17 standard. Seems this becomes a mainstream.
> 
> In Python float.hex() returns hexadecimal string representation. Is it a time to add more support of hexadecimal floating literals? Accept them in float constructor and in Python parser? And maybe add support of hexadecimal formatting ('%x' and '{:x}')?
> 
> _______________________________________________
> 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/

___________________________________________________
                               Dr Thibault HILAIRE

Université Pierre et Marie Curie (Associate Professor)
Computing Science Lab (LIP6)
Engineering school Polytech Paris UPMC

4 place Jussieu
75005 PARIS, France

tel: +33 (0)1.44.27.87.73
email: thibault.hilaire at lip6.fr
web: http://www.docmatic.fr

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170908/ba921b72/attachment-0001.html>


More information about the Python-ideas mailing list