Proposal: Hexadecimal floating point constants

Heinrich Apfelmus apfelmus at quantentunnel.de
Sat Feb 20 06:26:32 EST 2010


Nick Bowler wrote:
> I'd like to propose what I believe is a simple but valuable extension to
> Haskell that I haven't seen proposed elsewhere.
> 
> C has something it calls hexadecimal floating constants, and it would be
> very nice if Haskell had it too.  For floating point systems where the
> radix is a power of two (very common), they offer a means of clearly and
> exactly specifying any finite floating point value.
>
> [..]
> 
> Similarly, the greatest finite double value can be written as
> 0x1.fffffffffffffp+1023.
> 
> These constants have the form
> 
>   0x[HH][.HHHHH]p[+/-]DDD

If you don't want to wait on an (uncertain) inclusion into the Haskell
standard, you can implement a small helper function to that effect
yourself; essentially using  encodeFloat .


Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



More information about the Haskell-prime mailing list