<div dir="ltr">Moritz:<div><br></div><div>Looks like you're raising the same concern as in here: <a href="https://ghc.haskell.org/trac/ghc/ticket/13124">https://ghc.haskell.org/trac/ghc/ticket/13124</a></div><div><br></div><div>Long story short: You cannot encode -0.0 directly. You have to represent it as an expression, multiplying `-1` with `fromRational 0`.</div><div><br></div><div>Similar concerns apply to NaN and Infinity as well, though those cannot be written as literals to start with, so it isn't a big issue there.</div><div><br></div><div>-Levent.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Sep 17, 2017 at 7:02 AM, Moritz Angermann <span dir="ltr"><<a href="mailto:moritz.angermann@gmail.com" target="_blank">moritz.angermann@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi *,<br>
<br>
I just ran into the following case:<br>
<br>
> fromRat (-0 :: Rational) :: Double<br>
0.0<br>
<br>
> -0 :: Rational<br>
0 % 1<br>
<br>
How do I encode negative zero as a rational? The question come<br>
up as `CmmFloat` is defined as `CmmFloat  Rational Width` in<br>
compiler/cmm/CmmExpr.hs. And my code generator thus turned<br>
(Int, Rational) into a floating point expression, and when trying<br>
to turn it into a `double` value, I ended up getting bad negative<br>
zeros.<br>
<br>
This makes me believe I can’t actually encode `-0` as a Rational,<br>
and such `CmmFloat` will never contain `-0`?<br>
<br>
Cheers,<br>
 Moritz<br>
______________________________<wbr>_________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div><br></div>