Proposal: Hexadecimal floating point constants

Simon Peyton-Jones simonpj at microsoft.com
Mon Feb 22 08:15:46 EST 2010


| > 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 .

Or, alternatively, use quasiquoting
	
	[hex| 1.fffffp+1023 |]

where 'hex' is a Haskell function that parses the string.
	http://www.haskell.org/ghc/docs/latest/html/users_guide/template-haskell.html#th-quasiquotation

This has the advantage that you can use the constant in patterns too.

(In GHC 6.12 you have to say [$hex| 1.ffffp+1023 |], with a "$", but we're changing that for 6.14.  There's a thread on ghc-users about it.)

Simon



More information about the Haskell-prime mailing list