[Python-ideas] Hexadecimal floating literals
Chris Barker - NOAA Federal
chris.barker at noaa.gov
Wed Sep 20 20:44:03 EDT 2017
> And that's one of the reasons why the hexadecimal floating-point representation exist:
I suspect no one here thinks floathex representation is unimportant...
>
> To sum up:
> - In some specific context, hexadecimal floating-point constants make it easy for the programmers to reproduce the exact value. Typically, a software engineer who is concerned about floating-point accuracy would prepare hexadecimal floating-point constants for use in a program by generating them with special software (e.g., Maple, Mathematica, Sage or some multi-precision library). These hexadecimal literals have been added to C (since C99), Java, Lua, Ruby, Perl (since v5.22), etc. for the same reasons.
> - The exact grammar has been fully documented in the IEEE-754-2008 norm (section 5.12.13), and also in C99 (or C++17 and others)
> - Of course, hexadecimal floating-point can be manipulated with float.hex() and float.fromhex(), *but* it works from strings, and the translation is done at execution-time...
Right. But it addresses all of the points you make. The functionality
is there. Making a new literal will buy a slight improvement in
writability and performance.
Is that worth much in a dynamic language like python?
-CHB
More information about the Python-ideas
mailing list