Hacker News new | comments | show | ask | jobs | submit login

In Haskell, decimal literals can be inferred as any Fractional type (including Rational, which is precise), but they default to Double if there is no context that dictates otherwise.

    Prelude> 0.3 - 0.2 == 0.2 - (0.1 :: Rational)
Above, we explicitly declare one of the literals as Rational, and the rest are inferred as having the same type (since the standard library does not allow you to do arithmetics or comparisons between discrepant types).

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact