Moritz: Looks like you're raising the same concern as in here: https://ghc.haskell.org/trac/ghc/ticket/13124
Long story short: You cannot encode -0.0 directly. You have to represent it as an expression, multiplying `-1` with `fromRational 0`. 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. -Levent. On Sun, Sep 17, 2017 at 7:02 AM, Moritz Angermann < moritz.angerm...@gmail.com> wrote: > Hi *, > > I just ran into the following case: > > > fromRat (-0 :: Rational) :: Double > 0.0 > > > -0 :: Rational > 0 % 1 > > How do I encode negative zero as a rational? The question come > up as `CmmFloat` is defined as `CmmFloat Rational Width` in > compiler/cmm/CmmExpr.hs. And my code generator thus turned > (Int, Rational) into a floating point expression, and when trying > to turn it into a `double` value, I ended up getting bad negative > zeros. > > This makes me believe I can’t actually encode `-0` as a Rational, > and such `CmmFloat` will never contain `-0`? > > Cheers, > Moritz > _______________________________________________ > ghc-devs mailing list > ghc-devs@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs >
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs