Description
What version of Go are you using (go version
)?
1.11, but N/A
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env
)?
N/A
What did you do?
Read the fmt specs and the language spec, and ponder floating point representation.
What did you expect to see?
Support for hexadecimal floats.
What did you see instead?
No support for hexadecimal floats.
I'm aware that Go's decimal-parsing for floats is superior to that available to C compilers in a number of ways (see issue #12518), but people who want hexadecimal floats often prefer them for reasons beyond that. This does have some overlap with 12518's suggestion for allowing binary exponents with a p
suffix, but hexadecimal floats give stronger and easier-to-reason-about guarantees. With decimal representations, it is non-trivial for a human to tell at a glance whether the representation is precise. With hexadecimal floats, the representation is definitionally precise.
Ideally, this would be present in fmt (both for input and output), and also in numeric constants. C used %a
/%A
, and the format [-]0xh.hhhp[+-]d
, with the hexadecimal digits after the period optional, and I don't see any obvious reason to think this specification would cause problems. So far as I know, this wouldn't break any existing code (any valid hex literal would be a syntax error in current go), and it would make life marginally easier for some people doing numerical work.