-0 rational?

Moritz Angermann moritz.angermann at gmail.com
Sun Sep 17 14:02:46 UTC 2017

Hi *,

I just ran into the following case:

> fromRat (-0 :: Rational) :: Double

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

This makes me believe I can’t actually encode `-0` as a Rational,
and such `CmmFloat` will never contain `-0`?


More information about the ghc-devs mailing list