[ghc-steering-committee] Proposal: Accept proposal 37, Hex Float literals
Simon Peyton Jones
simonpj at microsoft.com
Wed Mar 1 09:59:26 UTC 2017
I’m also fine with this hex-floats thing
What’s the protocol? Should committee discussion take place by default on the proposal thread itself, with exceptional out-of-band private discussion on the mailing list? Or by-default private on the mailing list?
Simon
From: ghc-steering-committee [mailto:ghc-steering-committee-bounces at haskell.org] On Behalf Of Simon Marlow
Sent: 28 February 2017 13:37
To: Iavor Diatchki <iavor.diatchki at gmail.com>
Cc: ghc-steering-committee at haskell.org
Subject: Re: [ghc-steering-committee] Proposal: Accept proposal 37, Hex Float literals
No objections from me. Looks useful and not too costly in terms of extra complexity.
On 27 February 2017 at 21:34, Iavor Diatchki <iavor.diatchki at gmail.com<mailto:iavor.diatchki at gmail.com>> wrote:
Hello,
I was assigned to be the shepherd for the Hex Float proposal (https://github.com/ghc-proposals/ghc-proposals/pull/37<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fghc-proposals%2Fghc-proposals%2Fpull%2F37&data=02%7C01%7Csimonpj%40microsoft.com%7Cc043b1b23db44809543c08d45fdedd63%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636238858192460021&sdata=ce2UQC76fEIyTWo4rEY0UWo9AKfzCINM7q9nWuDAsSQ%3D&reserved=0>), so I would like to propose that we accept it for implementation in GHC.
This is a small change, which can be summarized as follows:
- allow floating point numbers to be written using hex digits.
The format is exactly the same as decimal floating point numbers, except for:
- the literals start with 0x
- the digits are in hex
- the exponent symbol is `p` or `P`, instead of `e` or `E`
- the exponent is in base 2, rather than base 10
This notation has become popular among people working with floating point numbers, as the numbers you write can be represented exactly, which is not the case for base 10 numbers.
The following points were discussed:
- the exact format to use, compared to what's allowed by other languages: we decided to just follow Haskell's decimal float notation, for least surprise
- should overflow (which becomes `Inf`) result in a warning? We decided that this is an orthogonal issue, also relevant to decimal floating point and made a GHC ticket (#13232)
- there is an odd interaction between floating point (both decimal and hex) and -XNegativeLiterals, related to negative 0, see ticket #13211
- changing the Read instances for Float and Double to recognize hex floats could break some programs, although that does not seem all that likely
- there is a question of how many extra pretty printing functions to add to `Numeric`: the current thinking is that maybe just one `showHFloat` is sufficient; the alternative is to add 5, mirroring the `show[E,F,G]Float` functions for decimals.
I also had a stab at implementing the basic notation here: https://phabricator.haskell.org/D3066
I haven't done the changes to the libraries yet.
Please let me know if you have any objections or suggestions on what might needs to be changed.
Cheers,
-Iavor
_______________________________________________
ghc-steering-committee mailing list
ghc-steering-committee at haskell.org<mailto:ghc-steering-committee at haskell.org>
https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.haskell.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fghc-steering-committee&data=02%7C01%7Csimonpj%40microsoft.com%7Cc043b1b23db44809543c08d45fdedd63%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636238858192460021&sdata=MHExzxUYwauMyUHRXudw9p9cbZX6VbjuZw6RR41bUG0%3D&reserved=0>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-steering-committee/attachments/20170301/0da4a87e/attachment-0001.html>
More information about the ghc-steering-committee
mailing list