<div dir="ltr">Quick update: version 0.2 of FloatingHex is now on hackage <span style="font-size:12.8px">(</span><a href="http://hackage.haskell.org/package/FloatingHex" target="_blank" style="font-size:12.8px">http://hackage.haskell.org/<wbr>package/<span class="gmail-il">FloatingHex</span></a><span style="font-size:12.8px">) which fixes a few glitches and makes the pretty-printer compatible with C's %a modifier. This brings the support on par with that in C/C++. The quasi-quoter is called qf, and the pretty-printer is called showHFloat, following the naming of other float-printers already available.</span></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 14, 2017 at 1:10 AM, Levent Erkok <span dir="ltr"><<a href="mailto:erkokl@gmail.com" target="_blank">erkokl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">FloatingHex (<a href="http://hackage.haskell.org/package/FloatingHex" target="_blank">http://hackage.haskell.org/<wbr>package/FloatingHex</a>) is a simple package that implement hexadecimal notation for floating point numbers, as described in p57-58 of <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf" target="_blank">http://www.open-std.org/<wbr>jtc1/sc22/wg14/www/docs/n1256.<wbr>pdf</a><div><br></div><div>The package provides a quasi-quoter for hexadecimal floats: hf, and a pretty-printer for floats to show them in this notation: showFFloat. (Note that the latter is not 100% compatible with C's %a modifier for printf, but it does render a faithful representation of its input.)</div><div><br></div><div>Hex-floats are useful as they allow writing floating-point constants without any loss of precision, while remaining human readable. For instance, the float 2 is written as 0x1p1. (With the quasiquoter, the syntax is [hf|0x1p1|].) This representation is to be preferred over decimal rendering where loss of precision can be a problem: Note that not all floating point numbers have a terminating decimal representation as currently required by the Haskell syntax.</div><div><br></div><div>It would be nice if Haskell itself allowed for such literals in the language specs itself, following the recent changes to other language standards. (Again, see p57-58 of <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf" target="_blank">http://www.open-std.org/<wbr>jtc1/sc22/wg14/www/docs/n1256.<wbr>pdf</a> for the new C standard.) In the mean time, I hope FloatingHex library will provide a workaround for the numerophilias amongst us.</div><div><br></div><div>Bug reports and improvements always welcome!</div><div><br></div><div>Cheers,</div><div><br></div><div>-Levent.</div><div><div><br></div><div><br></div></div></div>
</blockquote></div><br></div>